[EventEngine] Fix race on WorkQueue's most-recent element (#31557)

pull/31562/head
AJ Heller 2 years ago committed by GitHub
parent b8c2818c6b
commit 838340e619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/core/lib/event_engine/work_queue.cc

@ -147,15 +147,7 @@ EventEngine::Closure* WorkQueue::PopLocked(bool front)
std::memory_order_relaxed) == kInvalidTimestamp) {
return nullptr;
}
if (!most_recent_element_lock_.TryLock()) return nullptr;
absl::optional<Storage> ret;
if (GPR_LIKELY(most_recent_element_.has_value())) {
most_recent_element_enqueue_timestamp_.store(kInvalidTimestamp,
std::memory_order_relaxed);
ret = std::exchange(most_recent_element_, absl::nullopt);
}
most_recent_element_lock_.Unlock();
return ret->closure();
return TryPopMostRecentElement();
}
// the queue has elements, let's pop one and update timestamps
Storage ret_s;

Loading…
Cancel
Save