chenBright commented on code in PR #3647:
URL: https://github.com/apache/brpc/pull/3647#discussion_r4358027202
##########
test/brpc_controller_unittest.cpp:
##########
@@ -62,8 +65,8 @@ TEST_F(ControllerTest, notify_on_failed) {
cntl.NotifyOnCancel(brpc::NewCallback(&MyCancelCallback, &cancel));
// Trigger callback
brpc::Socket::SetFailed(id);
- usleep(20000); // sleep a while to wait for the canceling which will be
- // happening in another thread.
+ // The callback destroys this id after writing cancel.
+ ASSERT_EQ(0, bthread_id_join(cntl._oncancel_id));
Review Comment:
These tests intentionally exercise implementation details: the repository's
CMake, Bazel, and Make test configurations enable `-fno-access-control`, and
the existing Controller tests already access private state.
Joining `_oncancel_id` synchronizes with completion of the cancellation
callback, because the ID is destroyed after the callback returns. The public
RPC `call_id()` represents a different operation and cannot replace it.
A new production accessor would merely relocate this internal dependency, so
I am keeping the direct access in the test.
--
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]