Skip to content

Commit

Permalink
Use of non-standard port, and no junk left behind in redisxDestroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 11, 2024
1 parent 2a732e5 commit 3a472fe
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/redisx-net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 3a472fe

Please sign in to comment.