diff options
author | Jameson Nash <vtjnash@gmail.com> | 2013-02-12 16:53:37 -0500 |
---|---|---|
committer | Santiago Gimeno <santiago.gimeno@gmail.com> | 2017-12-20 22:17:52 +0100 |
commit | fd049399aa4ed8495928e375466970d98cb42e17 (patch) | |
tree | adc0450682d0f3864097a02f70473a897a35a122 /test/test-tcp-bind-error.c | |
parent | b01de7341f40e1f30d78178442b0b87a46b3b7a7 (diff) | |
download | libuv-fd049399aa4ed8495928e375466970d98cb42e17.tar.gz libuv-fd049399aa4ed8495928e375466970d98cb42e17.zip |
unix,tcp: avoid marking server sockets connected
It shouldn't be setting READABLE and WRITABLE on the socket server,
since they aren't, and this could confuse the client.
PR-URL: https://github.com/libuv/libuv/pull/1655
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'test/test-tcp-bind-error.c')
-rw-r--r-- | test/test-tcp-bind-error.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/test-tcp-bind-error.c b/test/test-tcp-bind-error.c index 10ed68e1..1456d081 100644 --- a/test/test-tcp-bind-error.c +++ b/test/test-tcp-bind-error.c @@ -214,3 +214,45 @@ TEST_IMPL(tcp_listen_without_bind) { MAKE_VALGRIND_HAPPY(); return 0; } + + +TEST_IMPL(tcp_bind_writable_flags) { + struct sockaddr_in addr; + uv_tcp_t server; + uv_buf_t buf; + uv_write_t write_req; + uv_shutdown_t shutdown_req; + int r; + + ASSERT(0 == uv_ip4_addr("0.0.0.0", TEST_PORT, &addr)); + r = uv_tcp_init(uv_default_loop(), &server); + ASSERT(r == 0); + r = uv_tcp_bind(&server, (const struct sockaddr*) &addr, 0); + ASSERT(r == 0); + r = uv_listen((uv_stream_t*)&server, 128, NULL); + ASSERT(r == 0); + + ASSERT(0 == uv_is_writable((uv_stream_t*) &server)); + ASSERT(0 == uv_is_readable((uv_stream_t*) &server)); + + buf = uv_buf_init("PING", 4); + r = uv_write(&write_req, (uv_stream_t*) &server, &buf, 1, NULL); + ASSERT(r == UV_EPIPE); + r = uv_shutdown(&shutdown_req, (uv_stream_t*) &server, NULL); +#ifdef _WIN32 + ASSERT(r == UV_EPIPE); +#else + ASSERT(r == UV_ENOTCONN); +#endif + r = uv_read_start((uv_stream_t*) &server, NULL, NULL); + ASSERT(r == UV_ENOTCONN); + + uv_close((uv_handle_t*)&server, close_cb); + + uv_run(uv_default_loop(), UV_RUN_DEFAULT); + + ASSERT(close_cb_called == 1); + + MAKE_VALGRIND_HAPPY(); + return 0; +} |