From 3a472fed751a342905d66d637d63ca4635239b77 Mon Sep 17 00:00:00 2001 From: Attila Kovacs Date: Wed, 11 Dec 2024 12:07:13 +0100 Subject: [PATCH] Use of non-standard port, and no junk left behind in redisxDestroy() --- src/redisx-net.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/redisx-net.c b/src/redisx-net.c index 2422a9a..25d1fca 100644 --- a/src/redisx-net.c +++ b/src/redisx-net.c @@ -699,7 +699,7 @@ Redis *redisxInit(const char *server) { } p->addr = inet_addr((char *) ipAddress); - p->port = REDISX_TCP_PORT; + p->port = p->port > 0 ? p->port : REDISX_TCP_PORT; p->protocol = REDISX_RESP2; // Default p->timeoutMillis = REDISX_DEFAULT_TIMEOUT_MILLIS; @@ -734,16 +734,30 @@ void redisxDestroy(Redis *redis) { for(i = REDISX_CHANNELS; --i >= 0; ) { ClientPrivate *cp = (ClientPrivate *) p->clients[i].priv; + if(!cp) continue; + pthread_mutex_destroy(&cp->readLock); pthread_mutex_destroy(&cp->writeLock); pthread_mutex_destroy(&cp->pendingLock); - if(cp != NULL) free(cp); + + redisxDestroyRESP(cp->attributes); + free(cp); } - free(p->clients); + + redisxDestroyRESP(p->helloData); + redisxClearConnectHooks(redis); + redisxClearSubscribers(redis); + + if(p->username) free(p->username); + if(p->password) free(p->password); + if(p->clients) free(p->clients); + free(p); rUnregisterServer(redis); + if(redis->id) free(redis->id); + free(redis); }