Skip to content

Commit

Permalink
Merge pull request alibaba#535 from Coldwings/fix-rpc-shutdown-test
Browse files Browse the repository at this point in the history
Fix on epoll-ng when testing in RpcTest shutdown
  • Loading branch information
lihuiba authored Aug 9, 2024
2 parents 33e3251 + 166b978 commit e1502a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions io/epoll-ng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ class EventEngineEPollNG : public MasterEventEngine,
return 0; // Event arrived
}
rm_interest(event);
// fire events in case of event during notify
wait_and_fire_events(0);
if (ret == 0) {
errno = ETIMEDOUT;
return -1;
Expand Down
8 changes: 4 additions & 4 deletions rpc/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,10 @@ TEST_F(RpcTest, shutdown) {
ASSERT_NE(nullptr, stub);
DEFER(pool->put_stub(ep, true));

photon::thread_create11([&]{
auto stopper = photon::thread_enable_join(photon::thread_create11([&]{
photon::thread_sleep(1);
sk->shutdown();
delete sk;
sk = nullptr;
});
}));

auto start = std::chrono::steady_clock::now();
while (true) {
Expand All @@ -415,6 +413,8 @@ TEST_F(RpcTest, shutdown) {
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
GTEST_ASSERT_GT(duration, 900);
GTEST_ASSERT_LT(duration, 1100);

photon::thread_join(stopper);
}

TEST_F(RpcTest, passive_shutdown) {
Expand Down

0 comments on commit e1502a4

Please sign in to comment.