diff options
author | antirez <antirez@gmail.com> | 2011-04-30 22:29:21 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2011-05-25 12:32:44 +0200 |
commit | 0f1d64ca577c8594e26b9e1663e49c8e1bc13757 (patch) | |
tree | 91d063179e0f557c9a3d6775fc498f26a49d4ea2 /src/networking.c | |
parent | 7585836e6eb1c0199e8d9ea2c3f7a0f67b03c00b (diff) | |
download | redis-0f1d64ca577c8594e26b9e1663e49c8e1bc13757.tar.gz |
Lua call of Redis command work in progress: sorry I have to go to the cinema to watch the Source Code movie
Diffstat (limited to 'src/networking.c')
-rw-r--r-- | src/networking.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/networking.c b/src/networking.c index 4a6a8afd8..b26c20595 100644 --- a/src/networking.c +++ b/src/networking.c @@ -14,14 +14,20 @@ redisClient *createClient(int fd) { redisClient *c = zmalloc(sizeof(redisClient)); c->bufpos = 0; - anetNonBlock(NULL,fd); - anetTcpNoDelay(NULL,fd); - if (aeCreateFileEvent(server.el,fd,AE_READABLE, - readQueryFromClient, c) == AE_ERR) - { - close(fd); - zfree(c); - return NULL; + /* passing -1 as fd it is possible to create a non connected client. + * This is useful since all the Redis commands needs to be executed + * in the context of a client. When commands are executed in other + * contexts (for instance a Lua script) we need a non connected client. */ + if (fd != -1) { + anetNonBlock(NULL,fd); + anetTcpNoDelay(NULL,fd); + if (aeCreateFileEvent(server.el,fd,AE_READABLE, + readQueryFromClient, c) == AE_ERR) + { + close(fd); + zfree(c); + return NULL; + } } selectDb(c,0); |