Commit c765dfdf authored by Gunjan Sharma's avatar Gunjan Sharma Committed by Tudor Bosman

Fix another race in Notification Queue

Summary: Consider a case we found that the queue is empty and unlocked and before our setActive(false) from SCOPE_EXIT gets called (or gets the lock) putMessageImpl got the lock. Now putMessage thinks that we donot want to add another signal but actually we do.

Test Plan:
Running mcreplay2 without running into this problem on a box.
Benchmark:

Reviewed By: davejwatson@fb.com

FB internal diff: D1428249
parent b6b4f60b
...@@ -576,6 +576,7 @@ void NotificationQueue<MessageT>::Consumer::handlerReady(uint16_t events) ...@@ -576,6 +576,7 @@ void NotificationQueue<MessageT>::Consumer::handlerReady(uint16_t events)
try { try {
if (UNLIKELY(queue_->queue_.empty())) { if (UNLIKELY(queue_->queue_.empty())) {
// If there is no message, we've reached the end of the queue, return. // If there is no message, we've reached the end of the queue, return.
setActive(false);
queue_->spinlock_.unlock(); queue_->spinlock_.unlock();
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment