Skip to content

Commit 22d9d0e

Browse files
committed
test: make abstract socket names unique per process
The .epoll/.select/.io_uring suites run as concurrent processes under `ctest --parallel`. testAbstractSocket() bound fixed abstract-namespace names, which are global per netns, so the processes raced to bind the same name and the loser got EADDRINUSE -- an intermittent CI failure on PRs that changed no code. Append getpid() to make each process's names unique.
1 parent ccdaf15 commit 22d9d0e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

test/unit/local_datagram_socket.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,19 @@ struct local_datagram_socket_test
296296
io_context ioc(Backend);
297297
auto ex = ioc.get_executor();
298298

299-
// Abstract socket: null byte prefix, no filesystem entry
299+
// Abstract socket: null byte prefix, no filesystem entry. The
300+
// abstract namespace is global per network namespace, so the
301+
// .epoll/.select/.io_uring variants -- separate processes run
302+
// concurrently by `ctest --parallel` -- must not share a name, or
303+
// they race to bind it and the loser gets EADDRINUSE. The pid makes
304+
// each process's names unique; abstract names are released on close,
305+
// so a reused pid from an exited run cannot clash.
306+
auto const tag =
307+
"corosio_test_abstract_dgram_" + std::to_string(::getpid());
300308
std::string abs_path1(1, '\0');
301-
abs_path1 += "corosio_test_abstract_dgram_1";
309+
abs_path1 += tag + "_1";
302310
std::string abs_path2(1, '\0');
303-
abs_path2 += "corosio_test_abstract_dgram_2";
311+
abs_path2 += tag + "_2";
304312

305313
local_datagram_socket s1(ioc);
306314
local_datagram_socket s2(ioc);

0 commit comments

Comments
 (0)