From a74d853241fa21ef4b6352fd39c25b4d4c6a4ab3 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 30 Dec 2024 14:27:43 -0800 Subject: ipc/tcp stream tests: use dup() to avoid confusion and hang in teardown This was observed only in the select poller, but the behavior of having the same file descriptor registered in the poller more than once is undefined. --- src/platform/ipc_stream_test.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/platform/ipc_stream_test.c') diff --git a/src/platform/ipc_stream_test.c b/src/platform/ipc_stream_test.c index e1ee86b0..7e5e7701 100644 --- a/src/platform/ipc_stream_test.c +++ b/src/platform/ipc_stream_test.c @@ -133,6 +133,11 @@ test_ipc_listen_activation(void) NUTS_PASS(nng_stream_dialer_alloc(&d, addr)); NUTS_PASS(nng_stream_listener_get_int(l1, NNG_OPT_LISTEN_FD, &fd)); + fd = dup(fd); + // dupe this because we need to separate the file descriptors to + // prevent confusion when we clean up (only one FD can be registered at + // a time!) + NUTS_ASSERT(fd >= -1); NUTS_PASS(nng_stream_listener_alloc(&l2, addr)); NUTS_PASS(nng_stream_listener_set_int(l2, NNG_OPT_LISTEN_FD, fd)); nng_stream_dialer_dial(d, aio2); -- cgit v1.2.3-70-g09d2