| 543 | } |
| 544 | |
| 545 | void Server::PUnsubscribeChannel(const std::string &pattern, redis::Connection *conn) { |
| 546 | std::lock_guard<std::mutex> guard(pubsub_channels_mu_); |
| 547 | |
| 548 | auto iter = pubsub_patterns_.find(pattern); |
| 549 | if (iter == pubsub_patterns_.end()) { |
| 550 | return; |
| 551 | } |
| 552 | |
| 553 | for (const auto &conn_ctx : iter->second) { |
| 554 | if (conn->GetFD() == conn_ctx.fd && conn->Owner() == conn_ctx.owner) { |
| 555 | iter->second.remove(conn_ctx); |
| 556 | if (iter->second.empty()) { |
| 557 | pubsub_patterns_.erase(iter); |
| 558 | } |
| 559 | break; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | void Server::SSubscribeChannel(const std::string &channel, redis::Connection *conn, uint16_t slot) { |
| 565 | assert((config_->cluster_enabled && slot < HASH_SLOTS_SIZE) || slot == 0); |