Wait with setting CONNECTED until there is an fd

This commit is contained in:
Pieter Noordhuis 2010-12-01 12:54:47 +01:00
parent 89c6927282
commit 2635feb0ac
2 changed files with 2 additions and 4 deletions

View File

@ -771,7 +771,6 @@ void redisFree(redisContext *c) {
redisContext *redisConnect(const char *ip, int port) { redisContext *redisConnect(const char *ip, int port) {
redisContext *c = redisContextInit(); redisContext *c = redisContextInit();
c->flags |= REDIS_BLOCK; c->flags |= REDIS_BLOCK;
c->flags |= REDIS_CONNECTED;
redisContextConnectTcp(c,ip,port); redisContextConnectTcp(c,ip,port);
return c; return c;
} }
@ -779,7 +778,6 @@ redisContext *redisConnect(const char *ip, int port) {
redisContext *redisConnectNonBlock(const char *ip, int port) { redisContext *redisConnectNonBlock(const char *ip, int port) {
redisContext *c = redisContextInit(); redisContext *c = redisContextInit();
c->flags &= ~REDIS_BLOCK; c->flags &= ~REDIS_BLOCK;
c->flags |= REDIS_CONNECTED;
redisContextConnectTcp(c,ip,port); redisContextConnectTcp(c,ip,port);
return c; return c;
} }
@ -787,7 +785,6 @@ redisContext *redisConnectNonBlock(const char *ip, int port) {
redisContext *redisConnectUnix(const char *path) { redisContext *redisConnectUnix(const char *path) {
redisContext *c = redisContextInit(); redisContext *c = redisContextInit();
c->flags |= REDIS_BLOCK; c->flags |= REDIS_BLOCK;
c->flags |= REDIS_CONNECTED;
redisContextConnectUnix(c,path); redisContextConnectUnix(c,path);
return c; return c;
} }
@ -795,7 +792,6 @@ redisContext *redisConnectUnix(const char *path) {
redisContext *redisConnectUnixNonBlock(const char *path) { redisContext *redisConnectUnixNonBlock(const char *path) {
redisContext *c = redisContextInit(); redisContext *c = redisContextInit();
c->flags &= ~REDIS_BLOCK; c->flags &= ~REDIS_BLOCK;
c->flags |= REDIS_CONNECTED;
redisContextConnectUnix(c,path); redisContextConnectUnix(c,path);
return c; return c;
} }

2
net.c
View File

@ -137,6 +137,7 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port) {
} }
c->fd = s; c->fd = s;
c->flags |= REDIS_CONNECTED;
return REDIS_OK; return REDIS_OK;
} }
@ -163,5 +164,6 @@ int redisContextConnectUnix(redisContext *c, const char *path) {
} }
c->fd = s; c->fd = s;
c->flags |= REDIS_CONNECTED;
return REDIS_OK; return REDIS_OK;
} }