mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Sentinel: rewrite callback chain removing instances with shared links
Otherwise pending commands callbacks will fire with a reference that no longer exists.
This commit is contained in:
parent
05dbc82005
commit
5a0516b5b9
@ -969,7 +969,23 @@ instanceLink *releaseInstanceLink(instanceLink *link, sentinelRedisInstance *ri)
|
|||||||
link->refcount--;
|
link->refcount--;
|
||||||
if (link->refcount != 0) {
|
if (link->refcount != 0) {
|
||||||
if (ri) {
|
if (ri) {
|
||||||
/* TODO: run the callbacks list and rebind. */
|
/* This instance may have pending callbacks in the hiredis async
|
||||||
|
* context, having as 'privdata' the instance that we are going to
|
||||||
|
* free. Let's rewrite the callback list, directly exploiting
|
||||||
|
* hiredis internal data structures, in order to bind them with
|
||||||
|
* a callback that will ignore the reply at all. */
|
||||||
|
redisCallback *cb;
|
||||||
|
redisCallbackList *callbacks = &link->cc->replies;
|
||||||
|
|
||||||
|
cb = callbacks->head;
|
||||||
|
while(cb) {
|
||||||
|
if (cb->privdata == ri) {
|
||||||
|
printf("HERE\n");
|
||||||
|
cb->fn = sentinelDiscardReplyCallback;
|
||||||
|
cb->privdata = NULL; /* Not strictly needed. */
|
||||||
|
}
|
||||||
|
cb = cb->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return link; /* Other active users. */
|
return link; /* Other active users. */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user