Copilot commented on code in PR #3750:
URL: https://github.com/apache/brpc/pull/3750#discussion_r4611336803
##########
src/brpc/rdma/rdma_endpoint.cpp:
##########
@@ -2038,9 +2060,13 @@ void RdmaEndpoint::PollingModeRelease(bthread_tag_t tag)
{
auto& pollers = group.pollers;
auto& running = group.running;
running.store(false, std::memory_order_relaxed);
- for (int i = 0; i < FLAGS_rdma_poller_num; ++i) {
- bthread_join(pollers[i].tid, nullptr);
+ for (auto& poller : pollers) {
+ if (poller.tid != INVALID_BTHREAD) {
+ bthread_join(poller.tid, nullptr);
+ poller.tid = INVALID_BTHREAD;
+ }
}
+ group.initialized.store(false, std::memory_order_release);
Review Comment:
`initialized` only prevents another initializer from claiming the group;
`PollingModeRelease` can still run while this initializer is starting pollers
or joining them during rollback. It can invalidate a `tid` before the
initializer joins it, or finish its loop before a later poller is started,
causing a data race and potentially leaving that poller unjoined. Serialize
initialize/release, or make release wait for the initialization/rollback owner
before joining and clearing the group.
##########
src/brpc/rdma/rdma_endpoint.cpp:
##########
@@ -1965,9 +1971,10 @@ int RdmaEndpoint::PollingModeInitialize(bthread_tag_t
tag,
auto& pollers = group.pollers;
auto& running = group.running;
bool expected = false;
- if (!running.compare_exchange_strong(expected, true)) {
+ if (!group.initialized.compare_exchange_strong(expected, true)) {
return 0;
Review Comment:
When a poller creation fails, `initialized` remains true while the first
caller joins the already-started pollers. A concurrent `PollingModeInitialize`
therefore takes this branch and returns success, but the rollback then clears
`running` and leaves the group stopped; `RdmaTransport::ContextInitOrDie`
treats the 0 return as a successful channel/server initialization, so that
caller can permanently use RDMA without any pollers. Competing initializers
need to wait for rollback and retry, or receive a failure, rather than
reporting success for a group that is being torn down.
--
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]