Permalink
Browse files

Issue #20 - redis-benchmark throwing socket error 10022

  • Loading branch information...
HenryRawas committed Nov 1, 2012
1 parent afe7873 commit 56b4b3bb8d735c2d8c2e79ea708d676c081e0875
Showing with 15 additions and 11 deletions.
  1. +10 −6 deps/hiredis/net.c
  2. +5 −5 msvs/RedisServer.sln
View
@@ -286,12 +286,13 @@ int redisCheckSocketError(redisContext *c, int fd) {
#ifdef _WIN32
int redisContextSetTimeout(redisContext *c, struct timeval tv) {
- if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,(const char *)&tv,sizeof(tv)) == SOCKET_ERROR ) {
+ DWORD ms = (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
+ if (setsockopt((int)c->fd,SOL_SOCKET,SO_RCVTIMEO,(const char *)&ms,sizeof(ms)) == SOCKET_ERROR ) {
errno = WSAGetLastError();
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)");
return REDIS_ERR;
}
- if (setsockopt(c->fd,SOL_SOCKET,SO_SNDTIMEO,(const char *)&tv,sizeof(tv)) == SOCKET_ERROR ) {
+ if (setsockopt((int)c->fd,SOL_SOCKET,SO_SNDTIMEO,(const char *)&ms,sizeof(ms)) == SOCKET_ERROR ) {
errno = WSAGetLastError();
__redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_SNDTIMEO)");
return REDIS_ERR;
@@ -342,7 +343,7 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
sa.sin_addr.s_addr = inAddress;
}
- if (redisSetBlocking(c,s,0) != REDIS_OK)
+ if (redisSetTcpNoDelay(c,s) != REDIS_OK)
return REDIS_ERR;
if (connect((SOCKET)s, (struct sockaddr*)&sa, sizeof(sa)) == -1) {
@@ -357,10 +358,13 @@ int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct t
}
}
- if (blocking && redisSetBlocking(c,s,1) != REDIS_OK)
+ if (blocking) {
+ if (redisSetBlocking(c,s,1) != REDIS_OK)
return REDIS_ERR;
- if (redisSetTcpNoDelay(c,s) != REDIS_OK)
- return REDIS_ERR;
+ } else {
+ if (redisSetBlocking(c,s,0) != REDIS_OK)
+ return REDIS_ERR;
+ }
c->fd = s;
c->flags |= REDIS_CONNECTED;
View
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RedisServer", "RedisServer.vcxproj", "{0C9DC382-C99F-7BF1-C6EF-96ED4C7CA003}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RedisServer", "RedisServer.vcxproj", "{46842776-68A5-EC98-6A09-1859BBFC73AA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hiredis", "hiredis\hiredis.vcxproj", "{13E85053-54B3-487B-8DDB-3430B1C1B3BF}"
EndProject
@@ -25,10 +25,10 @@ Global
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {0C9DC382-C99F-7BF1-C6EF-96ED4C7CA003}.Debug|Win32.ActiveCfg = Debug|Win32
- {0C9DC382-C99F-7BF1-C6EF-96ED4C7CA003}.Debug|Win32.Build.0 = Debug|Win32
- {0C9DC382-C99F-7BF1-C6EF-96ED4C7CA003}.Release|Win32.ActiveCfg = Release|Win32
- {0C9DC382-C99F-7BF1-C6EF-96ED4C7CA003}.Release|Win32.Build.0 = Release|Win32
+ {46842776-68A5-EC98-6A09-1859BBFC73AA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {46842776-68A5-EC98-6A09-1859BBFC73AA}.Debug|Win32.Build.0 = Debug|Win32
+ {46842776-68A5-EC98-6A09-1859BBFC73AA}.Release|Win32.ActiveCfg = Release|Win32
+ {46842776-68A5-EC98-6A09-1859BBFC73AA}.Release|Win32.Build.0 = Release|Win32
{13E85053-54B3-487B-8DDB-3430B1C1B3BF}.Debug|Win32.ActiveCfg = Debug|Win32
{13E85053-54B3-487B-8DDB-3430B1C1B3BF}.Debug|Win32.Build.0 = Debug|Win32
{13E85053-54B3-487B-8DDB-3430B1C1B3BF}.Release|Win32.ActiveCfg = Release|Win32

0 comments on commit 56b4b3b

Please sign in to comment.