aboutsummaryrefslogtreecommitdiff
path: root/src/platform/tcp_stream_test.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-30 14:27:43 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-30 14:27:43 -0800
commita74d853241fa21ef4b6352fd39c25b4d4c6a4ab3 (patch)
treed501426eab2f3dc641d9b67ac922bcc2dafd5a32 /src/platform/tcp_stream_test.c
parentfcc39223cfbd68d14a30b32a8be4f3fe0ab25e1c (diff)
downloadnng-a74d853241fa21ef4b6352fd39c25b4d4c6a4ab3.tar.gz
nng-a74d853241fa21ef4b6352fd39c25b4d4c6a4ab3.tar.bz2
nng-a74d853241fa21ef4b6352fd39c25b4d4c6a4ab3.zip
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.
Diffstat (limited to 'src/platform/tcp_stream_test.c')
-rw-r--r--src/platform/tcp_stream_test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/platform/tcp_stream_test.c b/src/platform/tcp_stream_test.c
index b9c20844..e2ca694b 100644
--- a/src/platform/tcp_stream_test.c
+++ b/src/platform/tcp_stream_test.c
@@ -115,10 +115,6 @@ test_tcp_stream(void)
NUTS_TRUE(sa2.s_in.sa_addr == sa.s_in.sa_addr);
NUTS_TRUE(sa2.s_in.sa_port == sa.s_in.sa_port);
- nng_stream_listener_close(l);
- nng_stream_dialer_close(d);
- nng_stream_listener_stop(l);
- nng_stream_dialer_stop(d);
nng_stream_listener_free(l);
nng_stream_dialer_free(d);
nng_aio_free(aio1);
@@ -214,6 +210,12 @@ test_tcp_listen_activation(void)
NUTS_PASS(nng_stream_dialer_alloc(&d, url));
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, "tcp4://"));
NUTS_PASS(nng_stream_listener_set_int(l2, NNG_OPT_LISTEN_FD, fd));
nng_stream_dialer_dial(d, aio2);