ext/libuv/test/test-poll.c in libuv-1.2.0 vs ext/libuv/test/test-poll.c in libuv-1.3.0

- old
+ new

@@ -20,11 +20,10 @@ */ #include <errno.h> #ifndef _WIN32 -# include <fcntl.h> # include <sys/socket.h> # include <unistd.h> #endif #include "uv.h" @@ -84,39 +83,21 @@ ; #endif } -static void set_nonblocking(uv_os_sock_t sock) { - int r; -#ifdef _WIN32 - unsigned long on = 1; - r = ioctlsocket(sock, FIONBIO, &on); - ASSERT(r == 0); -#else - int flags = fcntl(sock, F_GETFL, 0); - ASSERT(flags >= 0); - r = fcntl(sock, F_SETFL, flags | O_NONBLOCK); - ASSERT(r >= 0); -#endif -} - - -static uv_os_sock_t create_nonblocking_bound_socket( - struct sockaddr_in bind_addr) { +static uv_os_sock_t create_bound_socket (struct sockaddr_in bind_addr) { uv_os_sock_t sock; int r; sock = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); #ifdef _WIN32 ASSERT(sock != INVALID_SOCKET); #else ASSERT(sock >= 0); #endif - set_nonblocking(sock); - #ifndef _WIN32 { /* Allow reuse of the port. */ int yes = 1; r = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes); @@ -477,12 +458,10 @@ ASSERT(sock != INVALID_SOCKET); #else ASSERT(sock >= 0); #endif - set_nonblocking(sock); - connection_context = create_connection_context(sock, 1); connection_context->events = UV_READABLE | UV_WRITABLE; r = uv_poll_start(&connection_context->poll_handle, UV_READABLE | UV_WRITABLE, connection_poll_cb); @@ -500,11 +479,11 @@ struct sockaddr_in addr; uv_os_sock_t sock; int r; ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &addr)); - sock = create_nonblocking_bound_socket(addr); + sock = create_bound_socket(addr); context = create_server_context(sock); r = listen(sock, 100); ASSERT(r == 0); @@ -521,10 +500,10 @@ int r; ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &server_addr)); ASSERT(0 == uv_ip4_addr("0.0.0.0", 0, &addr)); - sock = create_nonblocking_bound_socket(addr); + sock = create_bound_socket(addr); context = create_connection_context(sock, 0); context->events = UV_READABLE | UV_WRITABLE; r = uv_poll_start(&context->poll_handle, UV_READABLE | UV_WRITABLE,