bring back uv_init

This commit is contained in:
Bert Belder 2011-08-31 04:19:07 +02:00
parent 56dcaf9b06
commit 3aec77f9d4
31 changed files with 70 additions and 25 deletions

View File

@ -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*);

View File

@ -84,7 +84,7 @@ BENCHMARK_IMPL(gethostbyname) {
return 1;
}
uv_init();
ares_callbacks = 0;
ares_errors = 0;

View File

@ -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();

View File

@ -198,7 +198,7 @@ static void pinger_new() {
BENCHMARK_IMPL(ping_pongs) {
uv_init();
start_time = uv_now();
pinger_new();

View File

@ -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();

View File

@ -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();

View File

@ -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);

View File

@ -314,7 +314,7 @@ static int dns_start(int port) {
HELPER_IMPL(dns_server) {
uv_init();
if (dns_start(TEST_PORT_2))
return 1;

View File

@ -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))

View File

@ -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);

View File

@ -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");
}

View File

@ -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);

View File

@ -180,7 +180,7 @@ static void client_connect() {
TEST_IMPL(delayed_accept) {
uv_init();
start_server();

View File

@ -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;

View File

@ -91,7 +91,7 @@ TEST_IMPL(gethostbyname) {
return 1;
}
uv_init();
printf("Start basic gethostbyname test\n");
prep_tcploopback();

View File

@ -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;
}
}

View File

@ -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);

View File

@ -299,6 +299,7 @@ TEST_IMPL(loop_handles) {
int i;
int r;
uv_init();
r = uv_prepare_init(uv_default_loop(), &prepare_1_handle);

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -153,7 +153,7 @@ TEST_IMPL(shutdown_eof) {
struct sockaddr_in server_addr;
int r;
uv_init();
qbuf.base = "Q";
qbuf.len = 1;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -176,6 +176,7 @@ TEST_IMPL(tcp_writealot) {
ASSERT(send_buffer != NULL);
uv_init();
r = uv_tcp_init(uv_default_loop(), client);

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);