Skip to content

Commit 8b4dc2c

Browse files
Eric Prud'hommeauxclaude
andcommitted
~ test_BNodeResolver: wake the MiniEndpoint accept loop on shutdown
On Linux, closing the listening fd does not unblock a thread in accept(2) (it does on macOS), so the destructor's thread.join() hung the ubuntu CI job at the 600s ctest timeout. Kick the loop with a self-connect after setting `stopping`, join, then close. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 4ea715c commit 8b4dc2c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎tests/test_BNodeResolver.cpp‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,15 @@ namespace {
291291
}
292292
~MiniEndpoint () {
293293
stopping = true;
294+
/* closing the fd does not wake a blocked accept(2) on Linux -
295+
* connect once to kick the loop, which then sees `stopping` */
294296
boost::system::error_code ec;
295-
acceptor.close(ec);
297+
boost::asio::io_context wakeIo;
298+
boost::asio::ip::tcp::socket wake(wakeIo);
299+
wake.connect(acceptor.local_endpoint(), ec);
300+
wake.close(ec);
296301
if (thread.joinable()) thread.join();
302+
acceptor.close(ec);
297303
}
298304
std::string url () const {
299305
std::ostringstream ss;
@@ -314,11 +320,11 @@ namespace {
314320
}
315321

316322
void run () {
317-
while (!stopping) {
323+
for (;;) {
318324
boost::asio::ip::tcp::socket sock(io);
319325
boost::system::error_code ec;
320326
acceptor.accept(sock, ec);
321-
if (ec) return; // acceptor closed - shut down
327+
if (ec || stopping) return;
322328
try { handle(sock); } catch (...) { }
323329
}
324330
}

0 commit comments

Comments
 (0)