diff --git a/src/unix/tcp.c b/src/unix/tcp.c index 50608da7..ee94ab3e 100644 --- a/src/unix/tcp.c +++ b/src/unix/tcp.c @@ -321,6 +321,6 @@ int uv_tcp_keepalive(uv_tcp_t* handle, int enable, unsigned int delay) { } -int uv_tcp_multiple_simultaneous_accepts(uv_tcp_t* handle, int enable) { +int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { return 0; } diff --git a/src/win/tcp.c b/src/win/tcp.c index c22d238a..f0860864 100644 --- a/src/win/tcp.c +++ b/src/win/tcp.c @@ -1094,7 +1094,7 @@ int uv_tcp_duplicate_socket(uv_tcp_t* handle, int pid, } -int uv_tcp_multiple_simultaneous_accepts(uv_tcp_t* handle, int enable) { +int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable) { if (handle->flags & UV_HANDLE_CONNECTION) { uv__set_artificial_error(handle->loop, UV_EINVAL); return -1; diff --git a/test/test-ipc.c b/test/test-ipc.c index d1f7bf10..d0c1abfb 100644 --- a/test/test-ipc.c +++ b/test/test-ipc.c @@ -230,3 +230,49 @@ TEST_IMPL(ipc_listen_before_write) { TEST_IMPL(ipc_listen_after_write) { return run_ipc_test("ipc_helper_listen_after_write"); } + + +#ifdef _WIN32 +TEST_IMPL(listen_with_simultaneous_accepts) { + uv_tcp_t server; + int r; + struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", TEST_PORT); + + r = uv_tcp_init(uv_default_loop(), &server); + ASSERT(r == 0); + + r = uv_tcp_bind(&server, addr); + ASSERT(r == 0); + + r = uv_tcp_simultaneous_accepts(&server, 1); + ASSERT(r == 0); + + r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); + ASSERT(r == 0); + ASSERT(server.reqs_pending == 32); + + return 0; +} + + +TEST_IMPL(listen_no_simultaneous_accepts) { + uv_tcp_t server; + int r; + struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", TEST_PORT); + + r = uv_tcp_init(uv_default_loop(), &server); + ASSERT(r == 0); + + r = uv_tcp_bind(&server, addr); + ASSERT(r == 0); + + r = uv_tcp_simultaneous_accepts(&server, 0); + ASSERT(r == 0); + + r = uv_listen((uv_stream_t*)&server, SOMAXCONN, NULL); + ASSERT(r == 0); + ASSERT(server.reqs_pending == 1); + + return 0; +} +#endif \ No newline at end of file diff --git a/test/test-list.h b/test/test-list.h index e1b2c3ce..70fd7845 100644 --- a/test/test-list.h +++ b/test/test-list.h @@ -113,6 +113,8 @@ TEST_DECLARE (threadpool_queue_work_simple) TEST_DECLARE (spawn_detect_pipe_name_collisions_on_windows) TEST_DECLARE (argument_escaping) TEST_DECLARE (environment_creation) +TEST_DECLARE (listen_with_simultaneous_accepts) +TEST_DECLARE (listen_no_simultaneous_accepts) #endif HELPER_DECLARE (tcp4_echo_server) HELPER_DECLARE (tcp6_echo_server) @@ -229,6 +231,8 @@ TASK_LIST_START TEST_ENTRY (spawn_detect_pipe_name_collisions_on_windows) TEST_ENTRY (argument_escaping) TEST_ENTRY (environment_creation) + TEST_ENTRY (listen_with_simultaneous_accepts) + TEST_ENTRY (listen_no_simultaneous_accepts) #endif TEST_ENTRY (fs_file_noent)