From becd47cb22d9189197bcb71e2e3cc29b87726ce8 Mon Sep 17 00:00:00 2001 From: Attila Kovacs Date: Wed, 11 Dec 2024 14:24:55 +0100 Subject: [PATCH] Fix regression in redisxInit() --- src/redisx-net.c | 12 ++++++------ test/src/test-hello.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/redisx-net.c b/src/redisx-net.c index d9fbec9..b668711 100644 --- a/src/redisx-net.c +++ b/src/redisx-net.c @@ -629,13 +629,17 @@ static void rUnregisterServer(const Redis *redis) { * @param cl * @param idx */ -static void rInitClient(RedisClient *cl, enum redisx_channel idx) { +static void rInitClient(Redis *redis, enum redisx_channel idx) { + RedisPrivate *p = (RedisPrivate *) redis->priv; + RedisClient *cl = &p->clients[idx]; ClientPrivate *cp; cp = calloc(1, sizeof(ClientPrivate)); x_check_alloc(cp); + cp->redis = redis; cp->idx = idx; + pthread_mutex_init(&cp->readLock, NULL); pthread_mutex_init(&cp->writeLock, NULL); pthread_mutex_init(&cp->pendingLock, NULL); @@ -860,11 +864,7 @@ Redis *redisxInit(const char *server) { x_check_alloc(p->clients); // Initialize clients. - for(i = REDISX_CHANNELS; --i >= 0; ) { - ClientPrivate *cp = (ClientPrivate *) p->clients[i].priv; - rInitClient(&p->clients[i], i); - cp->redis = redis; - } + for(i = REDISX_CHANNELS; --i >= 0; ) rInitClient(redis, i); // Alias clients redis->interactive = &p->clients[REDISX_INTERACTIVE_CHANNEL]; diff --git a/test/src/test-hello.c b/test/src/test-hello.c index 70f5593..f0fe224 100644 --- a/test/src/test-hello.c +++ b/test/src/test-hello.c @@ -17,7 +17,7 @@ int main() { Redis *redis = redisxInit("localhost"); RedisEntry *e; RESP *resp; - const char *json; + char *json; int n = -1; xSetDebug(TRUE);