Copilot commented on code in PR #3545:
URL: https://github.com/apache/brpc/pull/3545#discussion_r4089497896
##########
test/bthread_butex_multi_tag_unittest.cpp:
##########
@@ -132,15 +157,17 @@ void* butex_requeue_func2(void* arg) {
auto mutex = p->mutex;
auto cond = p->cond;
auto ack = p->ack;
- butex_wake_all_return2.push_back(bthread_self_tag());
+ butex_requeue_return2.push_back(bthread_self_tag());
std::unique_lock<bthread::Mutex> lk(*mutex);
ack->signal();
cond->wait(lk);
- butex_wake_all_return2.push_back(bthread_self_tag());
+ butex_requeue_return2.push_back(bthread_self_tag());
return nullptr;
}
TEST(BthreadButexMultiTest, butex_requeue) {
+ butex_requeue_return1.clear();
+ butex_requeue_return2.clear();
Review Comment:
The requeue test still notifies immediately after `ack.wait()`, but both
workers signal `ack` before calling `cond->wait()`. If either worker has not
yet captured the condition sequence and registered its butex waiter, these
notifications can be lost and the later `bthread_join` calls can block
indefinitely. Add `WaitForWaiter(tid1)` and `WaitForWaiter(tid2)` after
`ack.wait()` and before the first `notify_all()`, as done in the other
multi-tag cases.
--
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]