mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Change dictGetSafeIterator to dictGetIterator in pubsub (#12931)
In #12838, we misuse the safe iterator of the client dict, so we can't catch the synchronous release of the client if there is a bug. Since we realize that clients (even subscribers) are released with async free, we change the safe iterators of the client dict into unsafe iterators in `pubsub.c`. And I also remove redundant code.
This commit is contained in:
parent
b07174afc2
commit
85a239b363
@ -374,9 +374,8 @@ void pubsubShardUnsubscribeAllChannelsInSlot(unsigned int slot) {
|
||||
while ((de = dictNext(di)) != NULL) {
|
||||
robj *channel = dictGetKey(de);
|
||||
dict *clients = dictGetVal(de);
|
||||
if (dictSize(clients) == 0) goto cleanup;
|
||||
/* For each client subscribed to the channel, unsubscribe it. */
|
||||
dictIterator *iter = dictGetSafeIterator(clients);
|
||||
dictIterator *iter = dictGetIterator(clients);
|
||||
dictEntry *entry;
|
||||
while ((entry = dictNext(iter)) != NULL) {
|
||||
client *c = dictGetKey(entry);
|
||||
@ -390,7 +389,6 @@ void pubsubShardUnsubscribeAllChannelsInSlot(unsigned int slot) {
|
||||
}
|
||||
}
|
||||
dictReleaseIterator(iter);
|
||||
cleanup:
|
||||
server.shard_channel_count--;
|
||||
dictDelete(d, channel);
|
||||
}
|
||||
@ -529,7 +527,7 @@ int pubsubPublishMessageInternal(robj *channel, robj *message, pubsubtype type)
|
||||
if (de) {
|
||||
dict *clients = dictGetVal(de);
|
||||
dictEntry *entry;
|
||||
dictIterator *iter = dictGetSafeIterator(clients);
|
||||
dictIterator *iter = dictGetIterator(clients);
|
||||
while ((entry = dictNext(iter)) != NULL) {
|
||||
client *c = dictGetKey(entry);
|
||||
addReplyPubsubMessage(c,channel,message,*type.messageBulk);
|
||||
@ -557,7 +555,7 @@ int pubsubPublishMessageInternal(robj *channel, robj *message, pubsubtype type)
|
||||
sdslen(channel->ptr),0)) continue;
|
||||
|
||||
dictEntry *entry;
|
||||
dictIterator *iter = dictGetSafeIterator(clients);
|
||||
dictIterator *iter = dictGetIterator(clients);
|
||||
while ((entry = dictNext(iter)) != NULL) {
|
||||
client *c = dictGetKey(entry);
|
||||
addReplyPubsubPatMessage(c,pattern,channel,message);
|
||||
|
Loading…
Reference in New Issue
Block a user