diff --git a/hiredis.c b/hiredis.c index 80599db..9b74b5b 100644 --- a/hiredis.c +++ b/hiredis.c @@ -1025,7 +1025,7 @@ redisContext *redisConnect(const char *ip, int port) { return c; } -redisContext *redisConnectWithTimeout(const char *ip, int port, struct timeval tv) { +redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv) { redisContext *c; c = redisContextInit(); @@ -1061,7 +1061,7 @@ redisContext *redisConnectUnix(const char *path) { return c; } -redisContext *redisConnectUnixWithTimeout(const char *path, struct timeval tv) { +redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv) { redisContext *c; c = redisContextInit(); @@ -1086,7 +1086,7 @@ redisContext *redisConnectUnixNonBlock(const char *path) { } /* Set read/write timeout on a blocking socket. */ -int redisSetTimeout(redisContext *c, struct timeval tv) { +int redisSetTimeout(redisContext *c, const struct timeval tv) { if (c->flags & REDIS_BLOCK) return redisContextSetTimeout(c,tv); return REDIS_ERR; diff --git a/hiredis.h b/hiredis.h index 42290a1..c65098b 100644 --- a/hiredis.h +++ b/hiredis.h @@ -173,12 +173,12 @@ typedef struct redisContext { } redisContext; redisContext *redisConnect(const char *ip, int port); -redisContext *redisConnectWithTimeout(const char *ip, int port, struct timeval tv); +redisContext *redisConnectWithTimeout(const char *ip, int port, const struct timeval tv); redisContext *redisConnectNonBlock(const char *ip, int port); redisContext *redisConnectUnix(const char *path); -redisContext *redisConnectUnixWithTimeout(const char *path, struct timeval tv); +redisContext *redisConnectUnixWithTimeout(const char *path, const struct timeval tv); redisContext *redisConnectUnixNonBlock(const char *path); -int redisSetTimeout(redisContext *c, struct timeval tv); +int redisSetTimeout(redisContext *c, const struct timeval tv); int redisEnableKeepAlive(redisContext *c); void redisFree(redisContext *c); int redisBufferRead(redisContext *c); diff --git a/net.c b/net.c index 96ca63d..483b160 100644 --- a/net.c +++ b/net.c @@ -232,7 +232,7 @@ int redisCheckSocketError(redisContext *c, int fd) { return REDIS_OK; } -int redisContextSetTimeout(redisContext *c, struct timeval tv) { +int redisContextSetTimeout(redisContext *c, const struct timeval tv) { if (setsockopt(c->fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof(tv)) == -1) { __redisSetErrorFromErrno(c,REDIS_ERR_IO,"setsockopt(SO_RCVTIMEO)"); return REDIS_ERR; @@ -244,7 +244,7 @@ int redisContextSetTimeout(redisContext *c, struct timeval tv) { return REDIS_OK; } -int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout) { +int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout) { int s, rv; char _port[6]; /* strlen("65535"); */ struct addrinfo hints, *servinfo, *p; @@ -300,7 +300,7 @@ end: return rv; // Need to return REDIS_OK if alright } -int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout) { +int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout) { int s; int blocking = (c->flags & REDIS_BLOCK); struct sockaddr_un sa; diff --git a/net.h b/net.h index 36096fe..94b76f5 100644 --- a/net.h +++ b/net.h @@ -40,9 +40,9 @@ #endif int redisCheckSocketError(redisContext *c, int fd); -int redisContextSetTimeout(redisContext *c, struct timeval tv); -int redisContextConnectTcp(redisContext *c, const char *addr, int port, struct timeval *timeout); -int redisContextConnectUnix(redisContext *c, const char *path, struct timeval *timeout); +int redisContextSetTimeout(redisContext *c, const struct timeval tv); +int redisContextConnectTcp(redisContext *c, const char *addr, int port, const struct timeval *timeout); +int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout); int redisKeepAlive(redisContext *c, int interval); #endif