summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2018-05-13 18:08:57 -0700
committermichael-grunder <michael.grunder@gmail.com>2018-05-13 18:08:57 -0700
commit7a1acdfeb58b3e3a84a7b5d34af5ec1daae0f603 (patch)
treec936a04bdcf6ad8079a20a4e61aa1fbfb9def6f7 /net.c
parentc1af0e849d6387a4297a1e1066c107f6f72d8469 (diff)
parent58e6b87f51ba31b4a2954d0babe6b3cf7019c985 (diff)
Merge remote-tracking branch 'justinbrewer/hiredis-pr1' into posix-build-fixes
Diffstat (limited to 'net.c')
-rw-r--r--net.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/net.c b/net.c
index 33d9a82..5d50f7c 100644
--- a/net.c
+++ b/net.c
@@ -71,7 +71,7 @@ static void __redisSetErrorFromErrno(redisContext *c, int type, const char *pref
if (prefix != NULL)
len = snprintf(buf,sizeof(buf),"%s: ",prefix);
- __redis_strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len);
+ strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len);
__redisSetError(c,type,buf);
}
@@ -136,7 +136,7 @@ int redisKeepAlive(redisContext *c, int interval) {
val = interval;
-#ifdef _OSX
+#if defined(__APPLE__) && defined(__MACH__)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) {
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
return REDIS_ERR;
@@ -285,8 +285,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
* This is a bit ugly, but atleast it works and doesn't leak memory.
**/
if (c->tcp.host != addr) {
- if (c->tcp.host)
- free(c->tcp.host);
+ free(c->tcp.host);
c->tcp.host = strdup(addr);
}
@@ -299,8 +298,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port,
memcpy(c->timeout, timeout, sizeof(struct timeval));
}
} else {
- if (c->timeout)
- free(c->timeout);
+ free(c->timeout);
c->timeout = NULL;
}
@@ -412,7 +410,10 @@ addrretry:
error:
rv = REDIS_ERR;
end:
- freeaddrinfo(servinfo);
+ if(servinfo) {
+ freeaddrinfo(servinfo);
+ }
+
return rv; // Need to return REDIS_OK if alright
}
@@ -432,7 +433,7 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time
struct sockaddr_un sa;
long timeout_msec = -1;
- if (redisCreateSocket(c,AF_LOCAL) < 0)
+ if (redisCreateSocket(c,AF_UNIX) < 0)
return REDIS_ERR;
if (redisSetBlocking(c,0) != REDIS_OK)
return REDIS_ERR;
@@ -449,15 +450,14 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time
memcpy(c->timeout, timeout, sizeof(struct timeval));
}
} else {
- if (c->timeout)
- free(c->timeout);
+ free(c->timeout);
c->timeout = NULL;
}
if (redisContextTimeoutMsec(c,&timeout_msec) != REDIS_OK)
return REDIS_ERR;
- sa.sun_family = AF_LOCAL;
+ sa.sun_family = AF_UNIX;
strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1);
if (connect(c->fd, (struct sockaddr*)&sa, sizeof(sa)) == -1) {
if (errno == EINPROGRESS && !blocking) {