This is an automated email from the ASF dual-hosted git repository.
chenBright pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new 535d8f89 Stabilize backup request policy test cleanup (#3564)
535d8f89 is described below
commit 535d8f89f857b62c4bac9da7875c1fc79309cd0a
Author: Xiaofeng Wang <[email protected]>
AuthorDate: Sun Sep 27 10:57:26 2026 +0800
Stabilize backup request policy test cleanup (#3564)
---
test/brpc_channel_unittest.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/test/brpc_channel_unittest.cpp b/test/brpc_channel_unittest.cpp
index 27f711d4..1467939a 100644
--- a/test/brpc_channel_unittest.cpp
+++ b/test/brpc_channel_unittest.cpp
@@ -2205,6 +2205,7 @@ protected:
void TestBackupRequestPolicy(bool single_server, bool async,
bool short_connection) {
ASSERT_EQ(0, StartAccept(_ep));
+ bool connection_close_timed_out = false;
for (int i = 0; i < 2; ++i) {
bool backup = i == 0;
std::cout << " *** single=" << single_server
@@ -2234,17 +2235,24 @@ protected:
if (short_connection) {
// Sleep to let `_messenger' detect `Socket' being `SetFailed'
- const int64_t start_time = butil::cpuwide_time_us();
- while (_messenger.ConnectionCount() != 0) {
- ASSERT_LT(butil::cpuwide_time_us(), start_time +
100000L/*100ms*/);
+ const int64_t deadline =
+ butil::cpuwide_time_us() + 1000000L /* 1s */;
+ while (_messenger.ConnectionCount() != 0 &&
+ butil::cpuwide_time_us() < deadline) {
bthread_usleep(1000);
}
+ if (_messenger.ConnectionCount() != 0) {
+ connection_close_timed_out = true;
+ break;
+ }
} else {
ASSERT_GE(1ul, _messenger.ConnectionCount());
}
}
StopAndJoin();
+ EXPECT_FALSE(connection_close_timed_out)
+ << "Timed out waiting for short connections to close";
}
butil::EndPoint _ep;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]