Skip to content
Browse files

Merge commit '7feff64' into bksavecow

  • Loading branch information...
2 parents 7a6fc7d + 7feff64 commit e078cb5e76d8f4fec6ebcdbd09e67e40543460bd @HenryRawas HenryRawas committed Aug 8, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 deps/hiredis/net.c
View
12 deps/hiredis/net.c
@@ -324,8 +324,6 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
- if (redisSetTcpNoDelay(c,s) != REDIS_OK)
- return REDIS_ERR;
inAddress = inet_addr(addr);
if (inAddress == INADDR_NONE || inAddress == INADDR_ANY) {
@@ -336,14 +334,17 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
__redisSetError(c,REDIS_ERR_OTHER,
sdscatprintf(sdsempty(),"can't resolve: %s\n", addr));
closesocket(s);
- return REDIS_ERR;;
+ return REDIS_ERR;
}
memcpy(&sa.sin_addr, he->h_addr, sizeof(struct in_addr));
}
else {
sa.sin_addr.s_addr = inAddress;
}
+ if (redisSetBlocking(c,s,0) != REDIS_OK)
+ return REDIS_ERR;
+
if (connect((SOCKET)s, (struct sockaddr*)&sa, sizeof(sa)) == -1) {
errno = WSAGetLastError();
if ((errno == WSAEINVAL) || (errno == WSAEWOULDBLOCK))
@@ -356,6 +357,11 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
}
}
+ if (blocking && redisSetBlocking(c,s,1) != REDIS_OK)
+ return REDIS_ERR;
+ if (redisSetTcpNoDelay(c,s) != REDIS_OK)
+ return REDIS_ERR;
+
c->fd = s;
c->flags |= REDIS_CONNECTED;
return REDIS_OK;

0 comments on commit e078cb5

Please sign in to comment.
Something went wrong with that request. Please try again.