From: antirez Date: Tue, 24 Jul 2012 14:35:23 +0000 (+0200) Subject: Sentinel: check that instance still exists in reply callbacks. X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/8ab7e998d1d4fb67951f4f4ddb8cd110a444ba20 Sentinel: check that instance still exists in reply callbacks. We can't be sure the instance object still exists when the reply callback is called. --- diff --git a/src/sentinel.c b/src/sentinel.c index 39a278fe..d95e1942 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1145,8 +1145,8 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata sentinelRedisInstance *ri = c->data; redisReply *r; - ri->pending_commands--; - if (!reply) return; + if (ri) ri->pending_commands--; + if (!reply || !ri) return; r = reply; if (r->type == REDIS_REPLY_STRING) { @@ -1159,15 +1159,15 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; - ri->pending_commands--; + if (ri) ri->pending_commands--; } void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { sentinelRedisInstance *ri = c->data; redisReply *r; - ri->pending_commands--; - if (!reply) return; + if (ri) ri->pending_commands--; + if (!reply || !ri) return; r = reply; if (r->type == REDIS_REPLY_STATUS || @@ -1190,8 +1190,8 @@ void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privd sentinelRedisInstance *ri = c->data; redisReply *r; - ri->pending_commands--; - if (!reply) return; + if (ri) ri->pending_commands--; + if (!reply || !ri) return; r = reply; /* Only update pub_time if we actually published our message. Otherwise @@ -1206,7 +1206,7 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd sentinelRedisInstance *ri = c->data; redisReply *r; - if (!reply) return; + if (!reply || !ri) return; r = reply; /* Update the last activity in the pubsub channel. Note that since we @@ -1700,8 +1700,8 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p sentinelRedisInstance *ri = c->data; redisReply *r; - ri->pending_commands--; - if (!reply) return; + if (ri) ri->pending_commands--; + if (!reply || !ri) return; r = reply; /* Ignore every error or unexpected reply.