Unverified Commit 99c468c3 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

Fix crash caused by pubsubShardUnsubscribeAllChannelsInSlot not deleting the client (#12896)

The code does not delete the corresponding node when traversing clients,
resulting in a loop, causing the dictDelete() == DICT_OK assertion to
fail.

In addition, did a cleanup, in the dictCreate scenario, we can avoid a
dictFind call since the dict is empty.

Issue was introduced in #12804.
parent 5b1fe925
...@@ -295,8 +295,10 @@ int pubsubSubscribeChannel(client *c, robj *channel, pubsubtype type) { ...@@ -295,8 +295,10 @@ int pubsubSubscribeChannel(client *c, robj *channel, pubsubtype type) {
d_ptr = type.serverPubSubChannels(slot); d_ptr = type.serverPubSubChannels(slot);
if (*d_ptr == NULL) { if (*d_ptr == NULL) {
*d_ptr = dictCreate(&keylistDictType); *d_ptr = dictCreate(&keylistDictType);
de = NULL;
} else {
de = dictFind(*d_ptr, channel);
} }
de = dictFind(*d_ptr, channel);
if (de == NULL) { if (de == NULL) {
clients = listCreate(); clients = listCreate();
dictAdd(*d_ptr, channel, clients); dictAdd(*d_ptr, channel, clients);
...@@ -387,6 +389,7 @@ void pubsubShardUnsubscribeAllChannelsInSlot(unsigned int slot) { ...@@ -387,6 +389,7 @@ void pubsubShardUnsubscribeAllChannelsInSlot(unsigned int slot) {
if (clientTotalPubSubSubscriptionCount(c) == 0) { if (clientTotalPubSubSubscriptionCount(c) == 0) {
unmarkClientAsPubSub(c); unmarkClientAsPubSub(c);
} }
listDelNode(clients, ln);
} }
server.shard_channel_count--; server.shard_channel_count--;
dictDelete(d, channel); dictDelete(d, channel);
......
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