Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions source/common/grpc/google_async_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,20 @@ void GoogleAsyncStreamImpl::writeQueued() {
}

void GoogleAsyncStreamImpl::onCompletedOps() {
Thread::LockGuard lock(completed_ops_lock_);
while (!completed_ops_.empty()) {
// The items in completed_ops_ execute in the order they were originally added to the queue since
// both the post callback scheduled by the completionThread and the deferred deletion of the
// GoogleAsyncClientThreadLocal happen on the dispatcher thread.
std::deque<std::pair<GoogleAsyncTag::Operation, bool>> completed_ops;
{
Thread::LockGuard lock(completed_ops_lock_);
completed_ops = std::move(completed_ops_);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completed_opts_.clear() here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this implicit in move semantics?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a repeat of: https://github.com/envoyproxy/envoy/pull/14289/files/606f7af97a41567673a049b609df81cb3b7c99a9#r536419940

Added an ASSERT similar to the one in the dispatcher after a similar std::move.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right; I remember. OK that sounds fine and faster.

}

while (!completed_ops.empty()) {
GoogleAsyncTag::Operation op;
bool ok;
std::tie(op, ok) = completed_ops_.front();
completed_ops_.pop_front();
std::tie(op, ok) = completed_ops.front();
completed_ops.pop_front();
handleOpCompletion(op, ok);
}
}
Expand Down