summaryrefslogtreecommitdiff
path: root/hiredis.c
diff options
context:
space:
mode:
Diffstat (limited to 'hiredis.c')
-rw-r--r--hiredis.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hiredis.c b/hiredis.c
index a3b3edd..8b9ceca 100644
--- a/hiredis.c
+++ b/hiredis.c
@@ -48,6 +48,7 @@ extern int redisContextUpdateConnectTimeout(redisContext *c, const struct timeva
extern int redisContextUpdateCommandTimeout(redisContext *c, const struct timeval *timeout);
static redisContextFuncs redisContextDefaultFuncs = {
+ .close = redisNetClose,
.free_privctx = NULL,
.async_read = redisAsyncRead,
.async_write = redisAsyncWrite,
@@ -729,7 +730,10 @@ static redisContext *redisContextInit(void) {
void redisFree(redisContext *c) {
if (c == NULL)
return;
- redisNetClose(c);
+
+ if (c->funcs && c->funcs->close) {
+ c->funcs->close(c);
+ }
sdsfree(c->obuf);
redisReaderFree(c->reader);
@@ -766,7 +770,9 @@ int redisReconnect(redisContext *c) {
c->privctx = NULL;
}
- redisNetClose(c);
+ if (c->funcs && c->funcs->close) {
+ c->funcs->close(c);
+ }
sdsfree(c->obuf);
redisReaderFree(c->reader);