diff --git a/include/uv.h b/include/uv.h index ea6712e5..ff038125 100644 --- a/include/uv.h +++ b/include/uv.h @@ -81,6 +81,7 @@ typedef struct uv_work_s uv_work_t; * All callbacks in libuv are made asynchronously. That is they are never * made by the function that takes them as a parameter. */ +void uv_init(); uv_loop_t* uv_loop_new(); void uv_loop_delete(uv_loop_t*); diff --git a/test/benchmark-ares.c b/test/benchmark-ares.c index 0023f5c5..d4d88e03 100644 --- a/test/benchmark-ares.c +++ b/test/benchmark-ares.c @@ -84,7 +84,7 @@ BENCHMARK_IMPL(gethostbyname) { return 1; } - + uv_init(); ares_callbacks = 0; ares_errors = 0; diff --git a/test/benchmark-getaddrinfo.c b/test/benchmark-getaddrinfo.c index d7f294c3..00366e61 100644 --- a/test/benchmark-getaddrinfo.c +++ b/test/benchmark-getaddrinfo.c @@ -66,7 +66,7 @@ static void getaddrinfo_initiate(uv_getaddrinfo_t* handle) { BENCHMARK_IMPL(getaddrinfo) { int i; - + uv_init(); uv_update_time(); start_time = uv_now(); diff --git a/test/benchmark-ping-pongs.c b/test/benchmark-ping-pongs.c index 6509f56b..80567239 100644 --- a/test/benchmark-ping-pongs.c +++ b/test/benchmark-ping-pongs.c @@ -198,7 +198,7 @@ static void pinger_new() { BENCHMARK_IMPL(ping_pongs) { - + uv_init(); start_time = uv_now(); pinger_new(); diff --git a/test/benchmark-pound.c b/test/benchmark-pound.c index 9a3a8e3c..bae5e46f 100644 --- a/test/benchmark-pound.c +++ b/test/benchmark-pound.c @@ -275,7 +275,7 @@ static int pound_it(int concurrency, uint64_t start_time; /* in ns */ uint64_t end_time; - + uv_init(); uv_update_time(); start = uv_now(); diff --git a/test/benchmark-pump.c b/test/benchmark-pump.c index 5de9f017..7713a585 100644 --- a/test/benchmark-pump.c +++ b/test/benchmark-pump.c @@ -366,7 +366,7 @@ HELPER_IMPL(tcp_pump_server) { int r; type = TCP; - + uv_init(); listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT); /* Server */ @@ -388,7 +388,7 @@ HELPER_IMPL(pipe_pump_server) { int r; type = PIPE; - + uv_init(); /* Server */ server = (uv_stream_t*)&pipeServer; @@ -410,7 +410,7 @@ void tcp_pump(int n) { TARGET_CONNECTIONS = n; type = TCP; - + uv_init(); connect_addr = uv_ip4_addr("127.0.0.1", TEST_PORT); @@ -426,7 +426,7 @@ void pipe_pump(int n) { TARGET_CONNECTIONS = n; type = PIPE; - + uv_init(); /* Start making connections */ maybe_connect_some(); diff --git a/test/benchmark-spawn.c b/test/benchmark-spawn.c index 61c29a66..46ddca0e 100644 --- a/test/benchmark-spawn.c +++ b/test/benchmark-spawn.c @@ -130,7 +130,7 @@ BENCHMARK_IMPL(spawn) { int r; static int64_t start_time, end_time; - + uv_init(); r = uv_exepath(exepath, &exepath_size); ASSERT(r == 0); diff --git a/test/dns-server.c b/test/dns-server.c index a0655097..2e4a8f39 100644 --- a/test/dns-server.c +++ b/test/dns-server.c @@ -314,7 +314,7 @@ static int dns_start(int port) { HELPER_IMPL(dns_server) { - + uv_init(); if (dns_start(TEST_PORT_2)) return 1; diff --git a/test/echo-server.c b/test/echo-server.c index 9f67adcb..4d572dde 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -270,6 +270,7 @@ static int pipe_echo_start(char* pipeName) { HELPER_IMPL(tcp4_echo_server) { + uv_init(); uv_loop_t* loop = uv_default_loop(); if (tcp4_echo_start(TEST_PORT)) @@ -281,6 +282,7 @@ HELPER_IMPL(tcp4_echo_server) { HELPER_IMPL(tcp6_echo_server) { + uv_init(); uv_loop_t* loop = uv_default_loop(); if (tcp6_echo_start(TEST_PORT)) @@ -292,6 +294,7 @@ HELPER_IMPL(tcp6_echo_server) { HELPER_IMPL(pipe_echo_server) { + uv_init(); uv_loop_t* loop = uv_default_loop(); if (pipe_echo_start(TEST_PIPENAME)) diff --git a/test/test-async.c b/test/test-async.c index 3d841518..ccf259e2 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -182,6 +182,8 @@ static void prepare_cb(uv_prepare_t* handle, int status) { TEST_IMPL(async) { int r; + uv_init(); + r = uv_prepare_init(uv_default_loop(), &prepare_handle); ASSERT(r == 0); r = uv_prepare_start(&prepare_handle, prepare_cb); diff --git a/test/test-callback-stack.c b/test/test-callback-stack.c index 4af63648..d0f46924 100644 --- a/test/test-callback-stack.c +++ b/test/test-callback-stack.c @@ -176,6 +176,8 @@ static void connect_cb(uv_connect_t* req, int status) { TEST_IMPL(callback_stack) { struct sockaddr_in addr = uv_ip4_addr("127.0.0.1", TEST_PORT); + uv_init(); + if (uv_tcp_init(uv_default_loop(), &client)) { FATAL("uv_tcp_init failed"); } diff --git a/test/test-connection-fail.c b/test/test-connection-fail.c index 203049e0..099b1ad2 100644 --- a/test/test-connection-fail.c +++ b/test/test-connection-fail.c @@ -119,7 +119,7 @@ void connection_fail(uv_connect_cb connect_cb) { * expect an error. */ TEST_IMPL(connection_fail) { - + uv_init(); connection_fail(on_connect_with_close); @@ -136,6 +136,7 @@ TEST_IMPL(connection_fail) { * attempt. */ TEST_IMPL(connection_fail_doesnt_auto_close) { + uv_init(); uv_timer_init(uv_default_loop(), &timer); diff --git a/test/test-delayed-accept.c b/test/test-delayed-accept.c index 8ef76de6..85099519 100644 --- a/test/test-delayed-accept.c +++ b/test/test-delayed-accept.c @@ -180,7 +180,7 @@ static void client_connect() { TEST_IMPL(delayed_accept) { - + uv_init(); start_server(); diff --git a/test/test-getaddrinfo.c b/test/test-getaddrinfo.c index 0c803a49..a66941d4 100644 --- a/test/test-getaddrinfo.c +++ b/test/test-getaddrinfo.c @@ -67,6 +67,7 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle, TEST_IMPL(getaddrinfo_basic) { int r; + uv_init(); r = uv_getaddrinfo(uv_default_loop(), @@ -88,7 +89,7 @@ TEST_IMPL(getaddrinfo_basic) { TEST_IMPL(getaddrinfo_concurrent) { int i, r; - + uv_init(); for (i = 0; i < CONCURRENT_COUNT; i++) { callback_counts[i] = 0; diff --git a/test/test-gethostbyname.c b/test/test-gethostbyname.c index 10bcca13..689cc2f3 100644 --- a/test/test-gethostbyname.c +++ b/test/test-gethostbyname.c @@ -91,7 +91,7 @@ TEST_IMPL(gethostbyname) { return 1; } - + uv_init(); printf("Start basic gethostbyname test\n"); prep_tcploopback(); diff --git a/test/test-getsockname.c b/test/test-getsockname.c index 299d8b3b..2bdd76a9 100644 --- a/test/test-getsockname.c +++ b/test/test-getsockname.c @@ -288,7 +288,7 @@ static void udp_sender(void) { TEST_IMPL(getsockname_tcp) { - + uv_init(); if (tcp_listener(TEST_PORT)) return 1; @@ -316,4 +316,4 @@ TEST_IMPL(getsockname_udp) { ASSERT(getsocknamecount == 2); return 0; -} \ No newline at end of file +} diff --git a/test/test-idle.c b/test/test-idle.c index 3e7b8f11..6e959b97 100644 --- a/test/test-idle.c +++ b/test/test-idle.c @@ -60,6 +60,7 @@ static void idle_cb(uv_idle_t* handle, int status) { TEST_IMPL(idle_starvation) { int r; + uv_init(); r = uv_idle_init(uv_default_loop(), &idle_handle); diff --git a/test/test-loop-handles.c b/test/test-loop-handles.c index fd8d591c..b9f3be21 100644 --- a/test/test-loop-handles.c +++ b/test/test-loop-handles.c @@ -299,6 +299,7 @@ TEST_IMPL(loop_handles) { int i; int r; + uv_init(); r = uv_prepare_init(uv_default_loop(), &prepare_1_handle); diff --git a/test/test-ping-pong.c b/test/test-ping-pong.c index b2aa8fbd..700e5e93 100644 --- a/test/test-ping-pong.c +++ b/test/test-ping-pong.c @@ -221,7 +221,7 @@ static void pipe_pinger_new() { TEST_IMPL(tcp_ping_pong) { - + uv_init(); tcp_pinger_new(); uv_run(uv_default_loop()); @@ -233,7 +233,7 @@ TEST_IMPL(tcp_ping_pong) { TEST_IMPL(tcp_ping_pong_v6) { - + uv_init(); tcp_pinger_v6_new(); uv_run(uv_default_loop()); @@ -245,7 +245,7 @@ TEST_IMPL(tcp_ping_pong_v6) { TEST_IMPL(pipe_ping_pong) { - + uv_init(); pipe_pinger_new(); uv_run(uv_default_loop()); diff --git a/test/test-pipe-bind-error.c b/test/test-pipe-bind-error.c index e9b946b9..961bb870 100644 --- a/test/test-pipe-bind-error.c +++ b/test/test-pipe-bind-error.c @@ -45,6 +45,7 @@ TEST_IMPL(pipe_bind_error_addrinuse) { uv_pipe_t server1, server2; int r; + uv_init(); r = uv_pipe_init(uv_default_loop(), &server1); @@ -81,6 +82,7 @@ TEST_IMPL(pipe_bind_error_addrnotavail) { uv_pipe_t server; int r; + uv_init(); r = uv_pipe_init(uv_default_loop(), &server); @@ -104,6 +106,7 @@ TEST_IMPL(pipe_bind_error_inval) { uv_pipe_t server; int r; + uv_init(); r = uv_pipe_init(uv_default_loop(), &server); @@ -129,6 +132,7 @@ TEST_IMPL(pipe_listen_without_bind) { uv_pipe_t server; int r; + uv_init(); r = uv_pipe_init(uv_default_loop(), &server); diff --git a/test/test-ref.c b/test/test-ref.c index e3d37d8d..69dad1c0 100644 --- a/test/test-ref.c +++ b/test/test-ref.c @@ -24,6 +24,7 @@ TEST_IMPL(ref) { + uv_init(); uv_run(uv_default_loop()); return 0; } @@ -31,6 +32,7 @@ TEST_IMPL(ref) { TEST_IMPL(idle_ref) { uv_idle_t h; + uv_init(); uv_idle_init(uv_default_loop(), &h); uv_idle_start(&h, NULL); uv_unref(uv_default_loop()); @@ -41,6 +43,7 @@ TEST_IMPL(idle_ref) { TEST_IMPL(async_ref) { uv_async_t h; + uv_init(); uv_async_init(uv_default_loop(), &h, NULL); uv_unref(uv_default_loop()); uv_run(uv_default_loop()); @@ -50,6 +53,7 @@ TEST_IMPL(async_ref) { TEST_IMPL(prepare_ref) { uv_prepare_t h; + uv_init(); uv_prepare_init(uv_default_loop(), &h); uv_prepare_start(&h, NULL); uv_unref(uv_default_loop()); @@ -60,6 +64,7 @@ TEST_IMPL(prepare_ref) { TEST_IMPL(check_ref) { uv_check_t h; + uv_init(); uv_check_init(uv_default_loop(), &h); uv_check_start(&h, NULL); uv_unref(uv_default_loop()); @@ -78,6 +83,7 @@ static void prepare_cb(uv_prepare_t* handle, int status) { TEST_IMPL(unref_in_prepare_cb) { uv_prepare_t h; + uv_init(); uv_prepare_init(uv_default_loop(), &h); uv_prepare_start(&h, prepare_cb); diff --git a/test/test-shutdown-eof.c b/test/test-shutdown-eof.c index 2e49d538..f7ea80df 100644 --- a/test/test-shutdown-eof.c +++ b/test/test-shutdown-eof.c @@ -153,7 +153,7 @@ TEST_IMPL(shutdown_eof) { struct sockaddr_in server_addr; int r; - + uv_init(); qbuf.base = "Q"; qbuf.len = 1; diff --git a/test/test-spawn.c b/test/test-spawn.c index 1b896886..d86cd009 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -116,7 +116,7 @@ static void timer_cb(uv_timer_t* handle, int status) { TEST_IMPL(spawn_exit_code) { int r; - + uv_init(); init_process_options("spawn_helper1", exit_cb); @@ -137,7 +137,7 @@ TEST_IMPL(spawn_stdout) { int r; uv_pipe_t out; - + uv_init(); init_process_options("spawn_helper2", exit_cb); @@ -170,7 +170,7 @@ int r; uv_buf_t buf; char buffer[] = "hello-from-spawn_stdin"; - + uv_init(); init_process_options("spawn_helper3", exit_cb); @@ -204,7 +204,7 @@ int r; TEST_IMPL(spawn_and_kill) { int r; - + uv_init(); init_process_options("spawn_helper4", kill_cb); @@ -234,7 +234,7 @@ TEST_IMPL(spawn_detect_pipe_name_collisions_on_windows) { char name[64]; HANDLE pipe_handle; - + uv_init(); init_process_options("spawn_helper2", exit_cb); diff --git a/test/test-tcp-bind-error.c b/test/test-tcp-bind-error.c index 2a49f6ad..28c2f612 100644 --- a/test/test-tcp-bind-error.c +++ b/test/test-tcp-bind-error.c @@ -39,6 +39,7 @@ TEST_IMPL(tcp_bind_error_addrinuse) { uv_tcp_t server1, server2; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server1); @@ -74,6 +75,7 @@ TEST_IMPL(tcp_bind_error_addrnotavail_1) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -100,6 +102,8 @@ TEST_IMPL(tcp_bind_error_addrnotavail_2) { uv_tcp_t server; int r; + uv_init(); + r = uv_tcp_init(uv_default_loop(), &server); ASSERT(r == 0); r = uv_tcp_bind(&server, addr); @@ -124,6 +128,7 @@ TEST_IMPL(tcp_bind_error_fault) { garbage_addr = (struct sockaddr_in*) &garbage; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -150,6 +155,7 @@ TEST_IMPL(tcp_bind_error_inval) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -177,6 +183,7 @@ TEST_IMPL(tcp_bind_localhost_ok) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -192,6 +199,7 @@ TEST_IMPL(tcp_listen_without_bind) { int r; uv_tcp_t server; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); ASSERT(r == 0); diff --git a/test/test-tcp-bind6-error.c b/test/test-tcp-bind6-error.c index 836d47ad..74b930d6 100644 --- a/test/test-tcp-bind6-error.c +++ b/test/test-tcp-bind6-error.c @@ -39,6 +39,7 @@ TEST_IMPL(tcp_bind6_error_addrinuse) { uv_tcp_t server1, server2; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server1); @@ -74,6 +75,7 @@ TEST_IMPL(tcp_bind6_error_addrnotavail) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -100,6 +102,7 @@ TEST_IMPL(tcp_bind6_error_fault) { garbage_addr = (struct sockaddr_in6*) &garbage; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -126,6 +129,7 @@ TEST_IMPL(tcp_bind6_error_inval) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); @@ -153,6 +157,7 @@ TEST_IMPL(tcp_bind6_localhost_ok) { uv_tcp_t server; int r; + uv_init(); r = uv_tcp_init(uv_default_loop(), &server); diff --git a/test/test-tcp-writealot.c b/test/test-tcp-writealot.c index 2e994cab..1b1a03bf 100644 --- a/test/test-tcp-writealot.c +++ b/test/test-tcp-writealot.c @@ -176,6 +176,7 @@ TEST_IMPL(tcp_writealot) { ASSERT(send_buffer != NULL); + uv_init(); r = uv_tcp_init(uv_default_loop(), client); diff --git a/test/test-timer-again.c b/test/test-timer-again.c index 0998ca59..49cecf87 100644 --- a/test/test-timer-again.c +++ b/test/test-timer-again.c @@ -95,6 +95,7 @@ static void repeat_2_cb(uv_timer_t* handle, int status) { TEST_IMPL(timer_again) { int r; + uv_init(); start_time = uv_now(uv_default_loop()); diff --git a/test/test-timer.c b/test/test-timer.c index 17bcb84b..9e624cb1 100644 --- a/test/test-timer.c +++ b/test/test-timer.c @@ -90,6 +90,8 @@ TEST_IMPL(timer) { uv_timer_t repeat, never; int i, r; + uv_init(); + start_time = uv_now(uv_default_loop()); ASSERT(0 < start_time); diff --git a/test/test-udp-dgram-too-big.c b/test/test-udp-dgram-too-big.c index 2d172c06..92eb055e 100644 --- a/test/test-udp-dgram-too-big.c +++ b/test/test-udp-dgram-too-big.c @@ -65,6 +65,8 @@ TEST_IMPL(udp_dgram_too_big) { memset(dgram, 42, sizeof dgram); /* silence valgrind */ + uv_init(); + r = uv_udp_init(uv_default_loop(), &handle_); ASSERT(r == 0); diff --git a/test/test-udp-ipv6.c b/test/test-udp-ipv6.c index 6ff36b32..a32ba14d 100644 --- a/test/test-udp-ipv6.c +++ b/test/test-udp-ipv6.c @@ -100,6 +100,8 @@ static void do_test(uv_udp_recv_cb recv_cb, int bind_flags) { uv_buf_t buf; int r; + uv_init(); + addr6 = uv_ip6_addr("::0", TEST_PORT); r = uv_udp_init(uv_default_loop(), &server); diff --git a/test/test-udp-send-and-recv.c b/test/test-udp-send-and-recv.c index ab47e91c..bf73a563 100644 --- a/test/test-udp-send-and-recv.c +++ b/test/test-udp-send-and-recv.c @@ -170,6 +170,8 @@ TEST_IMPL(udp_send_and_recv) { addr = uv_ip4_addr("0.0.0.0", TEST_PORT); + uv_init(); + r = uv_udp_init(uv_default_loop(), &server); ASSERT(r == 0);