Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Commit

Permalink
Issue #20 - redis-benchmark throwing socket error 10022
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryRawas committed Nov 1, 2012
1 parent e4594e3 commit dea9244
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
16 changes: 10 additions & 6 deletions deps/hiredis/net.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions msvs/RedisServer.sln
@@ -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", "{4A8559D8-D9F9-BC1B-07E5-9B20A8E39BE8}"
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
Expand All @@ -25,10 +25,10 @@ Global
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4A8559D8-D9F9-BC1B-07E5-9B20A8E39BE8}.Debug|Win32.ActiveCfg = Debug|Win32
{4A8559D8-D9F9-BC1B-07E5-9B20A8E39BE8}.Debug|Win32.Build.0 = Debug|Win32
{4A8559D8-D9F9-BC1B-07E5-9B20A8E39BE8}.Release|Win32.ActiveCfg = Release|Win32
{4A8559D8-D9F9-BC1B-07E5-9B20A8E39BE8}.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
Expand Down

0 comments on commit dea9244

Please sign in to comment.