Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
windows: add tests for uv_tcp_simultaneous_accepts
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Zinkovsky committed Nov 1, 2011
1 parent 78f4b12 commit 9c6103a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/unix/tcp.c
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/win/tcp.c
Expand Up @@ -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;
Expand Down
46 changes: 46 additions & 0 deletions test/test-ipc.c
Expand Up @@ -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
4 changes: 4 additions & 0 deletions test/test-list.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9c6103a

Please sign in to comment.