| 716 | } |
| 717 | |
| 718 | void Server::OnEntryAddedToStream(const std::string &ns, const std::string &key, const redis::StreamEntryID &entry_id) { |
| 719 | std::lock_guard<std::mutex> guard(blocked_stream_consumers_mu_); |
| 720 | |
| 721 | auto iter = blocked_stream_consumers_.find(key); |
| 722 | if (iter == blocked_stream_consumers_.end() || iter->second.empty()) { |
| 723 | return; |
| 724 | } |
| 725 | |
| 726 | for (auto it = iter->second.begin(); it != iter->second.end();) { |
| 727 | auto consumer = *it; |
| 728 | if (consumer->ns == ns && entry_id > consumer->last_consumed_id) { |
| 729 | auto s = consumer->owner->EnableWriteEvent(consumer->fd); |
| 730 | if (!s.IsOK()) { |
| 731 | ERROR("[server] Failed to enable write event on blocked stream consumer {}: {}", consumer->fd, s.Msg()); |
| 732 | } |
| 733 | it = iter->second.erase(it); |
| 734 | } else { |
| 735 | ++it; |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | |
| 740 | void Server::BlockOnWait(redis::Connection *conn, rocksdb::SequenceNumber target_seq, uint64_t num_replicas) { |
| 741 | std::unique_lock<std::shared_mutex> guard(wait_contexts_mu_); |
no test coverage detected