Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
take the connect() time into account
Browse files Browse the repository at this point in the history
  • Loading branch information
weigon committed Jun 14, 2018
1 parent baa2556 commit 5e03511
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/helpers/router_component_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ bool RouterComponentTest::wait_for_port_ready(unsigned port, unsigned timeout_ms
std::shared_ptr<void> exit_freeaddrinfo(nullptr, [&](void*){freeaddrinfo(ainfo);});

const unsigned MSEC_STEP = 10;
const auto started = std::chrono::steady_clock::now();
do {
auto sock_id = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);
if (sock_id < 0) {
Expand All @@ -276,7 +277,7 @@ bool RouterComponentTest::wait_for_port_ready(unsigned port, unsigned timeout_ms
std::this_thread::sleep_for(std::chrono::milliseconds(step));
timeout_msec -= step;
}
} while(status < 0 && timeout_msec > 0);
} while(status < 0 && timeout_msec > std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - started).count());

return status >= 0;
}
Expand Down

0 comments on commit 5e03511

Please sign in to comment.