Unsubscribe from all the channels. Return the number of channels the * client was subscribed to. */
| 254 | /* Unsubscribe from all the channels. Return the number of channels the |
| 255 | * client was subscribed to. */ |
| 256 | int 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. */ |
no test coverage detected