Skip to content

Commit

Permalink
fix: Reply within async_dispatch block in squashed pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Oleshko <[email protected]>
  • Loading branch information
dranikpg committed Sep 8, 2023
1 parent e0af5fe commit 865cf7f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/facade/dragonfly_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,19 @@ void Connection::DispatchFiber(util::FiberSocketBase* peer) {
service_->DispatchManyCommands(absl::MakeSpan(args), cc_.get());
cc_->async_dispatch = false;

// Flush strictly before the dispatch queue is cleared so that no sync dispatch can occur
if (dispatch_q_.size() == args.size()) // Flush if no new messages appeared
builder->FlushBatch();

builder->SetBatchMode(false); // in case the next dispatch is sync
DCHECK(!cc_->sync_dispatch);

// Dispatch queue could have grown, so handle strictly as many as we executed
for (size_t i = 0; i < args.size(); i++) {
recycle(move(dispatch_q_.front()));
dispatch_q_.pop_front();
}

if (dispatch_q_.empty()) {
builder->FlushBatch();
builder->SetBatchMode(false); // in case the next dispatch is sync
}
} else {
MessageHandle msg = move(dispatch_q_.front());
dispatch_q_.pop_front();
Expand Down

0 comments on commit 865cf7f

Please sign in to comment.