MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / pubsubUnsubscribeAllChannels

Function pubsubUnsubscribeAllChannels

src/pubsub.cpp:256–273  ·  view source on GitHub ↗

Unsubscribe from all the channels. Return the number of channels the * client was subscribed to. */

Source from the content-addressed store, hash-verified

254/* Unsubscribe from all the channels. Return the number of channels the
255 * client was subscribed to. */
256int pubsubUnsubscribeAllChannels(client *c, int notify) {
257 int count = 0;
258 serverAssert(GlobalLocksAcquired());
259 if (dictSize(c->pubsub_channels) > 0) {
260 dictIterator *di = dictGetSafeIterator(c->pubsub_channels);
261 dictEntry *de;
262
263 while((de = dictNext(di)) != NULL) {
264 robj *channel = (robj*)dictGetKey(de);
265
266 count += pubsubUnsubscribeChannel(c,channel,notify);
267 }
268 dictReleaseIterator(di);
269 }
270 /* We were subscribed to nothing? Still reply to the client. */
271 if (notify && count == 0) addReplyPubsubUnsubscribed(c,NULL);
272 return count;
273}
274
275/* Unsubscribe from all the patterns. Return the number of patterns the
276 * client was subscribed from. */

Callers 4

unsubscribeCommandFunction · 0.85
RM_CallFunction · 0.85
freeClientFunction · 0.85
resetCommandFunction · 0.85

Calls 6

GlobalLocksAcquiredFunction · 0.85
dictGetSafeIteratorFunction · 0.85
pubsubUnsubscribeChannelFunction · 0.85
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70

Tested by

no test coverage detected