songgaoye opened a new pull request, #3738:
URL: https://github.com/apache/brpc/pull/3738

   ### What problem does this PR solve?
   
   Issue Number: resolve
   
   Problem Summary:
   
   `EventDispatcher::_stop` is read by the dispatcher event thread and
   `Running()`, while `Stop()` writes it from another thread. The field is a
   `volatile bool`, which does not provide synchronization, so these concurrent
   accesses form a C++ data race.
   
   The epoll/kqueue wakeup operations unblock the event loop, but they do not
   provide C++ memory-model synchronization for `_stop`.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - Replace `EventDispatcher::_stop` with `butil::atomic<bool>`.
   - Publish shutdown with a release store in `Stop()`.
   - Read shutdown state with acquire loads in `Running()` and both epoll/kqueue
     event loops.
   - Remove comments that treated epoll/kqueue operations as memory fences.
   - Add lifecycle coverage and a TSAN-oriented concurrent `Running()`/`Stop()`
     regression test.
   
   Side effects:
   
   - Performance effects:
   
     Shutdown-state reads are atomic. This path is not a request hot path.
   
   - Breaking backward compatibility:
   
     None.
   
   ---
   
   ### Check List:
   
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to