Commit 8ab7e998 authored by antirez's avatar antirez
Browse files

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.
parent e01a415d
...@@ -1145,8 +1145,8 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata ...@@ -1145,8 +1145,8 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
redisReply *r; redisReply *r;
ri->pending_commands--; if (ri) ri->pending_commands--;
if (!reply) return; if (!reply || !ri) return;
r = reply; r = reply;
if (r->type == REDIS_REPLY_STRING) { if (r->type == REDIS_REPLY_STRING) {
...@@ -1159,15 +1159,15 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata ...@@ -1159,15 +1159,15 @@ void sentinelInfoReplyCallback(redisAsyncContext *c, void *reply, void *privdata
void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { void sentinelDiscardReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
ri->pending_commands--; if (ri) ri->pending_commands--;
} }
void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) { void sentinelPingReplyCallback(redisAsyncContext *c, void *reply, void *privdata) {
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
redisReply *r; redisReply *r;
ri->pending_commands--; if (ri) ri->pending_commands--;
if (!reply) return; if (!reply || !ri) return;
r = reply; r = reply;
if (r->type == REDIS_REPLY_STATUS || if (r->type == REDIS_REPLY_STATUS ||
...@@ -1190,8 +1190,8 @@ void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privd ...@@ -1190,8 +1190,8 @@ void sentinelPublishReplyCallback(redisAsyncContext *c, void *reply, void *privd
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
redisReply *r; redisReply *r;
ri->pending_commands--; if (ri) ri->pending_commands--;
if (!reply) return; if (!reply || !ri) return;
r = reply; r = reply;
/* Only update pub_time if we actually published our message. Otherwise /* Only update pub_time if we actually published our message. Otherwise
...@@ -1206,7 +1206,7 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd ...@@ -1206,7 +1206,7 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
redisReply *r; redisReply *r;
if (!reply) return; if (!reply || !ri) return;
r = reply; r = reply;
/* Update the last activity in the pubsub channel. Note that since we /* Update the last activity in the pubsub channel. Note that since we
...@@ -1700,8 +1700,8 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p ...@@ -1700,8 +1700,8 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p
sentinelRedisInstance *ri = c->data; sentinelRedisInstance *ri = c->data;
redisReply *r; redisReply *r;
ri->pending_commands--; if (ri) ri->pending_commands--;
if (!reply) return; if (!reply || !ri) return;
r = reply; r = reply;
/* Ignore every error or unexpected reply. /* Ignore every error or unexpected reply.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment