| 574 | } |
| 575 | |
| 576 | void Server::SUnsubscribeChannel(const std::string &channel, redis::Connection *conn, uint16_t slot) { |
| 577 | assert((config_->cluster_enabled && slot < HASH_SLOTS_SIZE) || slot == 0); |
| 578 | std::lock_guard<std::mutex> guard(pubsub_shard_channels_mu_); |
| 579 | |
| 580 | auto iter = pubsub_shard_channels_[slot].find(channel); |
| 581 | if (iter == pubsub_shard_channels_[slot].end()) { |
| 582 | return; |
| 583 | } |
| 584 | |
| 585 | for (const auto &conn_ctx : iter->second) { |
| 586 | if (conn->GetFD() == conn_ctx.fd && conn->Owner() == conn_ctx.owner) { |
| 587 | iter->second.remove(conn_ctx); |
| 588 | if (iter->second.empty()) { |
| 589 | pubsub_shard_channels_[slot].erase(iter); |
| 590 | } |
| 591 | break; |
| 592 | } |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | void Server::GetSChannelsByPattern(const std::string &pattern, std::vector<std::string> *channels) { |
| 597 | std::lock_guard<std::mutex> guard(pubsub_shard_channels_mu_); |