diff options
author | theanarkh <2923878201@qq.com> | 2022-06-11 12:32:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-11 00:32:08 -0400 |
commit | 8bcd689c048af5aab26842ac5ff903fa3192d57c (patch) | |
tree | 6dbcd6b73c44d2240d6a31a79eb95a78691e6080 /test/test-tcp-bind-error.c | |
parent | d938c104e1f27deea44a99f2936ad753eab19d7a (diff) | |
download | libuv-8bcd689c048af5aab26842ac5ff903fa3192d57c.tar.gz libuv-8bcd689c048af5aab26842ac5ff903fa3192d57c.zip |
tcp,pipe: fail `bind` or `listen` after `close` (#3641)
Return `UV_EINVAL` in `bind` and `listen` when `handle` is
`UV_HANDLE_CLOSING` or `UV_HANDLE_CLOSED`.
Fixes: https://github.com/libuv/libuv/issues/3503
Diffstat (limited to 'test/test-tcp-bind-error.c')
-rw-r--r-- | test/test-tcp-bind-error.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test-tcp-bind-error.c b/test/test-tcp-bind-error.c index fdd1fe07..c3ca6ec8 100644 --- a/test/test-tcp-bind-error.c +++ b/test/test-tcp-bind-error.c @@ -297,3 +297,21 @@ TEST_IMPL(tcp_bind_writable_flags) { MAKE_VALGRIND_HAPPY(); return 0; } + +TEST_IMPL(tcp_bind_or_listen_error_after_close) { + uv_tcp_t tcp; + struct sockaddr_in addr; + + memset(&addr, 0, sizeof(addr)); + addr.sin_addr.s_addr = htonl(INADDR_ANY); + addr.sin_port = htons(9999); + addr.sin_family = AF_INET; + + ASSERT_EQ(uv_tcp_init(uv_default_loop(), &tcp), 0); + uv_close((uv_handle_t*) &tcp, NULL); + ASSERT_EQ(uv_tcp_bind(&tcp, (struct sockaddr*) &addr, 0), UV_EINVAL); + ASSERT_EQ(uv_listen((uv_stream_t*) &tcp, 5, NULL), UV_EINVAL); + ASSERT_EQ(uv_run(uv_default_loop(), UV_RUN_DEFAULT), 0); + MAKE_VALGRIND_HAPPY(); + return 0; +} |