From 04b6aaeb4415fd689353a12298274d81afa21efd Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 8 Jun 2011 12:02:42 +0200 Subject: [PATCH] API Change: Move close_cb to uv_close from init functions --- desired-api.md | 18 ++---- test/benchmark-ping-pongs.c | 8 +-- test/benchmark-pump.c | 19 +++---- test/echo-server.c | 20 +++---- test/test-async.c | 12 ++-- test/test-bind-error.c | 28 +++++---- test/test-callback-stack.c | 11 ++-- test/test-connection-fail.c | 17 +++--- test/test-delayed-accept.c | 19 +++---- test/test-loop-handles.c | 110 ++++++++++++++++-------------------- test/test-ping-pong.c | 9 ++- test/test-shutdown-eof.c | 12 ++-- test/test-tcp-writealot.c | 7 +-- test/test-timer-again.c | 13 ++--- test/test-timer.c | 21 +++---- uv-unix.c | 39 +++++++------ uv-win.c | 46 +++++++-------- uv.h | 19 +++---- 18 files changed, 190 insertions(+), 238 deletions(-) diff --git a/desired-api.md b/desired-api.md index 21f65b7b..9faa5759 100644 --- a/desired-api.md +++ b/desired-api.md @@ -48,8 +48,7 @@ Begins listening for connections. The accept callback is level-triggered. int uv_accept(uv_tcp_server_t* server, - uv_tcp_t* client, - uv_close_cb close_cb); + uv_tcp_t* client); Accepts a connection. This should be called after the accept callback is made. The `client` parameter should be uninitialized memory; `uv_accept` is @@ -90,8 +89,7 @@ Stops reading from the stream. int uv_write_req_init(uv_write_req_t*, uv_stream_t*, uv_buf_t bufs[], - int butcnf, - uv_close_cb close_cb); + int butcnf); Initiates a write request on a stream. @@ -110,8 +108,7 @@ or a server-side connection (one that was initialized with `uv_accept`) int uv_connect_req_init(uv_connect_req_t* req, uv_tcp_t* socket, - struct sockaddr* addr, - uv_close_cb close_cb); + struct sockaddr* addr); Initiates a request to open a connection. @@ -130,8 +127,7 @@ completion of the request. int uv_connect_req_init(uv_connect_req_t* req, uv_tcp_t* socket, - struct sockaddr* addr, - uv_close_cb close_cb); + struct sockaddr* addr); Initializes the connection request. Returning 0 indicates success, -1 if there was an error. The following values can be retrieved from @@ -148,8 +144,7 @@ channel is shutdown. Once a shutdown request is initiated on a stream, the stream will allow no more writes. int uv_shutdown_req_init(uv_shutdown_req_t*, - uv_stream_t* parent, - uv_close_cb close_cb); + uv_stream_t* parent); Initializes the shutdown request. @@ -159,7 +154,6 @@ Initializes the shutdown request. int uv_write_req_init(uv_write_req_t*, uv_stream_t*, uv_buf_t bufs[], - int butcnf, - uv_close_cb close_cb); + int butcnf); Initiates a write request on a stream. diff --git a/test/benchmark-ping-pongs.c b/test/benchmark-ping-pongs.c index 644102df..4d7f5ff9 100644 --- a/test/benchmark-ping-pongs.c +++ b/test/benchmark-ping-pongs.c @@ -78,11 +78,9 @@ static void buf_free(uv_buf_t uv_buf_t) { } -static void pinger_close_cb(uv_handle_t* handle, int status) { +static void pinger_close_cb(uv_handle_t* handle) { pinger_t* pinger; - ASSERT(status == 0); - pinger = (pinger_t*)handle->data; LOGF("ping_pongs: %d roundtrips/s\n", (1000 * pinger->pongs) / TIME); @@ -141,7 +139,7 @@ static void pinger_read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { } ASSERT(pinger_shutdown_cb_called == 1); - uv_close((uv_handle_t*)tcp); + uv_close((uv_handle_t*)tcp, pinger_close_cb); return; } @@ -190,7 +188,7 @@ static void pinger_new() { pinger->pongs = 0; /* Try to connec to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(&pinger->tcp, pinger_close_cb); + r = uv_tcp_init(&pinger->tcp); ASSERT(!r); pinger->tcp.data = pinger; diff --git a/test/benchmark-pump.c b/test/benchmark-pump.c index a0fe00a4..1e704075 100644 --- a/test/benchmark-pump.c +++ b/test/benchmark-pump.c @@ -118,16 +118,13 @@ static void read_show_stats() { -void write_sockets_close_cb(uv_handle_t* handle, int status) { - ASSERT(status == 0); +void write_sockets_close_cb(uv_handle_t* handle) { /* If any client closes, the process is done. */ exit(0); } -void read_sockets_close_cb(uv_handle_t* handle, int status) { - ASSERT(status == 0); - +void read_sockets_close_cb(uv_handle_t* handle) { free(handle); read_sockets--; @@ -136,7 +133,7 @@ void read_sockets_close_cb(uv_handle_t* handle, int status) { */ if (uv_now() - start_time > 1000 && read_sockets == 0) { read_show_stats(); - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, NULL); } } @@ -147,7 +144,7 @@ static void start_stats_collection() { /* Show-stats timer */ stats_left = STATS_COUNT; - r = uv_timer_init(&timer_handle, NULL); + r = uv_timer_init(&timer_handle); ASSERT(r == 0); r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL); ASSERT(r == 0); @@ -165,7 +162,7 @@ static void read_cb(uv_tcp_t* tcp, int bytes, uv_buf_t buf) { } if (bytes < 0) { - uv_close((uv_handle_t*)tcp); + uv_close((uv_handle_t*)tcp, read_sockets_close_cb); return; } @@ -239,7 +236,7 @@ static void maybe_connect_some() { max_connect_socket < write_sockets + MAX_SIMULTANEOUS_CONNECTS) { tcp = &write_handles[max_connect_socket++]; - r = uv_tcp_init(tcp, write_sockets_close_cb); + r = uv_tcp_init(tcp); ASSERT(r == 0); req = req_alloc(); @@ -259,7 +256,7 @@ static void connection_cb(uv_tcp_t* s, int status) { tcp = malloc(sizeof(uv_tcp_t)); - r = uv_accept(s, tcp, read_sockets_close_cb); + r = uv_accept(s, tcp); ASSERT(r == 0); r = uv_read_start(tcp, buf_alloc, read_cb); @@ -350,7 +347,7 @@ HELPER_IMPL(pump_server) { listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT); /* Server */ - r = uv_tcp_init(&server, NULL); + r = uv_tcp_init(&server); ASSERT(r == 0); r = uv_bind(&server, listen_addr); ASSERT(r == 0); diff --git a/test/echo-server.c b/test/echo-server.c index 2c441398..0ba3bd4b 100644 --- a/test/echo-server.c +++ b/test/echo-server.c @@ -37,7 +37,8 @@ static uv_tcp_t server; static void after_write(uv_req_t* req, int status); static void after_read(uv_tcp_t*, int nread, uv_buf_t buf); -static void on_close(uv_handle_t* peer, int status); +static void on_close(uv_handle_t* peer); +static void on_server_close(uv_handle_t* handle); static void on_connection(uv_tcp_t*, int status); @@ -59,7 +60,7 @@ static void after_write(uv_req_t* req, int status) { static void after_shutdown(uv_req_t* req, int status) { - uv_close(req->handle); + uv_close(req->handle, on_close); free(req); } @@ -94,7 +95,7 @@ static void after_read(uv_tcp_t* handle, int nread, uv_buf_t buf) { if (!server_closed) { for (i = 0; i < nread; i++) { if (buf.base[i] == 'Q') { - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, on_server_close); server_closed = 1; } } @@ -111,10 +112,8 @@ static void after_read(uv_tcp_t* handle, int nread, uv_buf_t buf) { } -static void on_close(uv_handle_t* peer, int status) { - if (status != 0) { - fprintf(stdout, "Socket error\n"); - } +static void on_close(uv_handle_t* peer) { + free(peer); } @@ -135,7 +134,7 @@ static void on_connection(uv_tcp_t* server, int status) { handle = (uv_tcp_t*) malloc(sizeof *handle); ASSERT(handle != NULL); - r = uv_accept(server, handle, on_close); + r = uv_accept(server, handle); ASSERT(r == 0); r = uv_read_start(handle, echo_alloc, after_read); @@ -143,9 +142,8 @@ static void on_connection(uv_tcp_t* server, int status) { } -static void on_server_close(uv_handle_t* handle, int status) { +static void on_server_close(uv_handle_t* handle) { ASSERT(handle == (uv_handle_t*)&server); - ASSERT(status == 0); } @@ -153,7 +151,7 @@ static int echo_start(int port) { struct sockaddr_in addr = uv_ip4_addr("0.0.0.0", port); int r; - r = uv_tcp_init(&server, on_server_close); + r = uv_tcp_init(&server); if (r) { /* TODO: Error codes */ fprintf(stderr, "Socket creation error\n"); diff --git a/test/test-async.c b/test/test-async.c index 3bbd6ec5..d820bf26 100644 --- a/test/test-async.c +++ b/test/test-async.c @@ -112,10 +112,8 @@ void thread3_entry(void *arg) { #endif -static void close_cb(uv_handle_t* handle, int status) { +static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); - ASSERT(status == 0); - close_cb_called++; } @@ -129,7 +127,7 @@ static void async1_cb(uv_handle_t* handle, int status) { if (async1_cb_called > 2 && !async1_closed) { async1_closed = 1; - uv_close(handle); + uv_close(handle, close_cb); } } @@ -174,7 +172,7 @@ static void prepare_cb(uv_handle_t* handle, int status) { #endif case 1: - r = uv_close(handle); + r = uv_close(handle, close_cb); ASSERT(r == 0); break; @@ -191,12 +189,12 @@ TEST_IMPL(async) { uv_init(); - r = uv_prepare_init(&prepare_handle, close_cb); + r = uv_prepare_init(&prepare_handle); ASSERT(r == 0); r = uv_prepare_start(&prepare_handle, prepare_cb); ASSERT(r == 0); - r = uv_async_init(&async1_handle, async1_cb, close_cb); + r = uv_async_init(&async1_handle, async1_cb); ASSERT(r == 0); #if 0 diff --git a/test/test-bind-error.c b/test/test-bind-error.c index de682fe5..587224ac 100644 --- a/test/test-bind-error.c +++ b/test/test-bind-error.c @@ -28,10 +28,8 @@ static int close_cb_called = 0; -static void close_cb(uv_handle_t* handle, int status) { +static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); - ASSERT(status == 0); - close_cb_called++; } @@ -43,12 +41,12 @@ TEST_IMPL(bind_error_addrinuse) { uv_init(); - r = uv_tcp_init(&server1, close_cb); + r = uv_tcp_init(&server1); ASSERT(r == 0); r = uv_bind(&server1, addr); ASSERT(r == 0); - r = uv_tcp_init(&server2, close_cb); + r = uv_tcp_init(&server2); ASSERT(r == 0); r = uv_bind(&server2, addr); ASSERT(r == 0); @@ -60,8 +58,8 @@ TEST_IMPL(bind_error_addrinuse) { ASSERT(uv_last_error().code == UV_EADDRINUSE); - uv_close((uv_handle_t*)&server1); - uv_close((uv_handle_t*)&server2); + uv_close((uv_handle_t*)&server1, close_cb); + uv_close((uv_handle_t*)&server2, close_cb); uv_run(); @@ -78,7 +76,7 @@ TEST_IMPL(bind_error_addrnotavail_1) { uv_init(); - r = uv_tcp_init(&server, close_cb); + r = uv_tcp_init(&server); ASSERT(r == 0); r = uv_bind(&server, addr); @@ -87,7 +85,7 @@ TEST_IMPL(bind_error_addrnotavail_1) { ASSERT(uv_last_error().code == UV_EADDRNOTAVAIL); } - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, close_cb); uv_run(); @@ -104,13 +102,13 @@ TEST_IMPL(bind_error_addrnotavail_2) { uv_init(); - r = uv_tcp_init(&server, close_cb); + r = uv_tcp_init(&server); ASSERT(r == 0); r = uv_bind(&server, addr); ASSERT(r == -1); ASSERT(uv_last_error().code == UV_EADDRNOTAVAIL); - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, close_cb); uv_run(); @@ -130,14 +128,14 @@ TEST_IMPL(bind_error_fault) { uv_init(); - r = uv_tcp_init(&server, close_cb); + r = uv_tcp_init(&server); ASSERT(r == 0); r = uv_bind(&server, *garbage_addr); ASSERT(r == -1); ASSERT(uv_last_error().code == UV_EFAULT); - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, close_cb); uv_run(); @@ -156,7 +154,7 @@ TEST_IMPL(bind_error_inval) { uv_init(); - r = uv_tcp_init(&server, close_cb); + r = uv_tcp_init(&server); ASSERT(r == 0); r = uv_bind(&server, addr1); ASSERT(r == 0); @@ -165,7 +163,7 @@ TEST_IMPL(bind_error_inval) { ASSERT(uv_last_error().code == UV_EINVAL); - uv_close((uv_handle_t*)&server); + uv_close((uv_handle_t*)&server, close_cb); uv_run(); diff --git a/test/test-callback-stack.c b/test/test-callback-stack.c index 10a308a1..7e60f098 100644 --- a/test/test-callback-stack.c +++ b/test/test-callback-stack.c @@ -52,8 +52,7 @@ static uv_buf_t alloc_cb(uv_tcp_t* tcp, size_t size) { } -static void close_cb(uv_handle_t* handle, int status) { - ASSERT(status == 0); +static void close_cb(uv_handle_t* handle) { ASSERT(nested == 0 && "close_cb must be called from a fresh stack"); close_cb_called++; @@ -82,7 +81,7 @@ static void read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { ASSERT(uv_last_error().code == UV_EOF); nested++; - if (uv_close((uv_handle_t*)tcp)) { + if (uv_close((uv_handle_t*)tcp, close_cb)) { FATAL("uv_close failed"); } nested--; @@ -127,7 +126,7 @@ static void timer_cb(uv_handle_t* handle, int status) { timer_cb_called++; - r = uv_close(handle); + r = uv_close(handle, close_cb); ASSERT(r == 0); } @@ -145,7 +144,7 @@ static void write_cb(uv_req_t* req, int status) { /* back to our receive buffer when we start reading. This maximizes the */ /* tempation for the backend to use dirty stack for calling read_cb. */ nested++; - r = uv_timer_init(&timer, close_cb); + r = uv_timer_init(&timer); ASSERT(r == 0); r = uv_timer_start(&timer, timer_cb, 500, 0); ASSERT(r == 0); @@ -185,7 +184,7 @@ TEST_IMPL(callback_stack) { uv_init(); - if (uv_tcp_init(&client, &close_cb)) { + if (uv_tcp_init(&client)) { FATAL("uv_tcp_init failed"); } diff --git a/test/test-connection-fail.c b/test/test-connection-fail.c index bacf5878..fe765197 100644 --- a/test/test-connection-fail.c +++ b/test/test-connection-fail.c @@ -36,14 +36,12 @@ static int timer_close_cb_calls; static int timer_cb_calls; -static void on_close(uv_handle_t* handle, int status) { - ASSERT(status == 0); +static void on_close(uv_handle_t* handle) { close_cb_calls++; } -static void timer_close_cb(uv_handle_t* handle, int status) { - ASSERT(status == 0); +static void timer_close_cb(uv_handle_t* handle) { timer_close_cb_calls++; } @@ -61,20 +59,21 @@ static void timer_cb(uv_handle_t* handle, int status) { ASSERT(connect_cb_calls == 1); /* Close the tcp handle. */ - uv_close((uv_handle_t*)&tcp); + uv_close((uv_handle_t*)&tcp, on_close); /* Close the timer. */ - uv_close(handle); + uv_close(handle, timer_close_cb); } static void on_connect_with_close(uv_req_t *req, int status) { + ASSERT(&tcp == (uv_tcp_t*) req->handle); ASSERT(status == -1); ASSERT(uv_last_error().code == UV_ECONNREFUSED); connect_cb_calls++; ASSERT(close_cb_calls == 0); - uv_close(req->handle); + uv_close(req->handle, on_close); } @@ -99,7 +98,7 @@ void connection_fail(uv_connect_cb connect_cb) { server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT); /* Try to connec to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(&tcp, on_close); + r = uv_tcp_init(&tcp); ASSERT(!r); /* We are never doing multiple reads/connects at a time anyway. */ @@ -141,7 +140,7 @@ TEST_IMPL(connection_fail) { TEST_IMPL(connection_fail_doesnt_auto_close) { uv_init(); - uv_timer_init(&timer, timer_close_cb); + uv_timer_init(&timer); connection_fail(on_connect_without_close); diff --git a/test/test-delayed-accept.c b/test/test-delayed-accept.c index a3790fc1..8db7c502 100644 --- a/test/test-delayed-accept.c +++ b/test/test-delayed-accept.c @@ -41,9 +41,8 @@ static uv_buf_t alloc_cb(uv_tcp_t* tcp, size_t size) { } -static void close_cb(uv_handle_t* handle, int status) { +static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); - ASSERT(status == 0); free(handle); @@ -61,23 +60,23 @@ static void do_accept(uv_handle_t* timer_handle, int status) { ASSERT(accepted_handle != NULL); server = (uv_tcp_t*)timer_handle->data; - r = uv_accept(server, accepted_handle, close_cb); + r = uv_accept(server, accepted_handle); ASSERT(r == 0); do_accept_called++; /* Immediately close the accepted handle. */ - r = uv_close((uv_handle_t*)accepted_handle); + r = uv_close((uv_handle_t*)accepted_handle, close_cb); ASSERT(r == 0); /* After accepting the two clients close the server handle */ if (do_accept_called == 2) { - r = uv_close((uv_handle_t*)server); + r = uv_close((uv_handle_t*)server, close_cb); ASSERT(r == 0); } /* Dispose the timer. */ - r = uv_close(timer_handle); + r = uv_close(timer_handle, close_cb); ASSERT(r == 0); } @@ -92,7 +91,7 @@ static void connection_cb(uv_tcp_t* tcp, int status) { ASSERT(timer_handle != NULL); /* Accept the client after 1 second */ - r = uv_timer_init(timer_handle, close_cb); + r = uv_timer_init(timer_handle); ASSERT(r == 0); timer_handle->data = tcp; @@ -111,7 +110,7 @@ static void start_server() { ASSERT(server != NULL); - r = uv_tcp_init(server, close_cb); + r = uv_tcp_init(server); ASSERT(r == 0); r = uv_bind(server, addr); @@ -132,7 +131,7 @@ static void read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { free(buf.base); } - uv_close((uv_handle_t*)tcp); + uv_close((uv_handle_t*)tcp, close_cb); } @@ -162,7 +161,7 @@ static void client_connect() { ASSERT(client != NULL); ASSERT(connect_req != NULL); - r = uv_tcp_init(client, close_cb); + r = uv_tcp_init(client); ASSERT(r == 0); uv_req_init(connect_req, (uv_handle_t*)client, connect_cb); diff --git a/test/test-loop-handles.c b/test/test-loop-handles.c index a32e3686..fa9cc18c 100644 --- a/test/test-loop-handles.c +++ b/test/test-loop-handles.c @@ -117,8 +117,15 @@ static void timer_cb(uv_handle_t* handle, int status) { } -static void timer_close_cb(uv_handle_t* handle, int status) { - FATAL("timer_close_cb should not be called"); +static void idle_2_close_cb(uv_handle_t* handle) { + LOG("IDLE_2_CLOSE_CB\n"); + + ASSERT(handle == (uv_handle_t*)&idle_2_handle); + + ASSERT(idle_2_is_active); + + idle_2_close_cb_called++; + idle_2_is_active = 0; } @@ -132,24 +139,11 @@ static void idle_2_cb(uv_handle_t* handle, int status) { idle_2_cb_called++; - r = uv_close(handle); + r = uv_close(handle, idle_2_close_cb); ASSERT(r == 0); } -static void idle_2_close_cb(uv_handle_t* handle, int status){ - LOG("IDLE_2_CLOSE_CB\n"); - - ASSERT(handle == (uv_handle_t*)&idle_2_handle); - ASSERT(status == 0); - - ASSERT(idle_2_is_active); - - idle_2_close_cb_called++; - idle_2_is_active = 0; -} - - static void idle_1_cb(uv_handle_t* handle, int status) { int r; @@ -162,7 +156,7 @@ static void idle_1_cb(uv_handle_t* handle, int status) { /* Init idle_2 and make it active */ if (!idle_2_is_active) { - r = uv_idle_init(&idle_2_handle, idle_2_close_cb); + r = uv_idle_init(&idle_2_handle); ASSERT(r == 0); r = uv_idle_start(&idle_2_handle, idle_2_cb); ASSERT(r == 0); @@ -180,16 +174,39 @@ static void idle_1_cb(uv_handle_t* handle, int status) { } -static void idle_1_close_cb(uv_handle_t* handle, int status){ +static void idle_1_close_cb(uv_handle_t* handle) { LOG("IDLE_1_CLOSE_CB\n"); ASSERT(handle != NULL); - ASSERT(status == 0); idle_1_close_cb_called++; } +static void prepare_1_close_cb(uv_handle_t* handle) { + LOG("PREPARE_1_CLOSE_CB"); + ASSERT(handle == (uv_handle_t*)&prepare_1_handle); + + prepare_1_close_cb_called++; +} + + +static void check_close_cb(uv_handle_t* handle) { + LOG("CHECK_CLOSE_CB\n"); + ASSERT(handle == (uv_handle_t*)&check_handle); + + check_close_cb_called++; +} + + +static void prepare_2_close_cb(uv_handle_t* handle) { + LOG("PREPARE_2_CLOSE_CB\n"); + ASSERT(handle == (uv_handle_t*)&prepare_2_handle); + + prepare_2_close_cb_called++; +} + + static void check_cb(uv_handle_t* handle, int status) { int i, r; @@ -213,22 +230,22 @@ static void check_cb(uv_handle_t* handle, int status) { } else { /* End of the test - close all handles */ - r = uv_close((uv_handle_t*)&prepare_1_handle); + r = uv_close((uv_handle_t*)&prepare_1_handle, prepare_1_close_cb); ASSERT(r == 0); - r = uv_close((uv_handle_t*)&check_handle); + r = uv_close((uv_handle_t*)&check_handle, check_close_cb); ASSERT(r == 0); - r = uv_close((uv_handle_t*)&prepare_2_handle); + r = uv_close((uv_handle_t*)&prepare_2_handle, prepare_2_close_cb); ASSERT(r == 0); for (i = 0; i < IDLE_COUNT; i++) { - r = uv_close((uv_handle_t*)&idle_1_handles[i]); + r = uv_close((uv_handle_t*)&idle_1_handles[i], idle_1_close_cb); ASSERT(r == 0); } /* This handle is closed/recreated every time, close it only if it is */ /* active.*/ if (idle_2_is_active) { - r = uv_close((uv_handle_t*)&idle_2_handle); + r = uv_close((uv_handle_t*)&idle_2_handle, idle_2_close_cb); ASSERT(r == 0); } } @@ -237,15 +254,6 @@ static void check_cb(uv_handle_t* handle, int status) { } -static void check_close_cb(uv_handle_t* handle, int status){ - LOG("CHECK_CLOSE_CB\n"); - ASSERT(handle == (uv_handle_t*)&check_handle); - ASSERT(status == 0); - - check_close_cb_called++; -} - - static void prepare_2_cb(uv_handle_t* handle, int status) { int r; @@ -270,15 +278,6 @@ static void prepare_2_cb(uv_handle_t* handle, int status) { } -static void prepare_2_close_cb(uv_handle_t* handle, int status) { - LOG("PREPARE_2_CLOSE_CB\n"); - ASSERT(handle == (uv_handle_t*)&prepare_2_handle); - ASSERT(status == 0); - - prepare_2_close_cb_called++; -} - - static void prepare_1_cb(uv_handle_t* handle, int status) { int r; @@ -304,38 +303,29 @@ static void prepare_1_cb(uv_handle_t* handle, int status) { } -static void prepare_1_close_cb(uv_handle_t* handle, int status){ - LOG("PREPARE_1_CLOSE_CB"); - ASSERT(handle == (uv_handle_t*)&prepare_1_handle); - ASSERT(status == 0); - - prepare_1_close_cb_called++; -} - - TEST_IMPL(loop_handles) { int i; int r; uv_init(); - r = uv_prepare_init(&prepare_1_handle, prepare_1_close_cb); + r = uv_prepare_init(&prepare_1_handle); ASSERT(r == 0); r = uv_prepare_start(&prepare_1_handle, prepare_1_cb); ASSERT(r == 0); - r = uv_check_init(&check_handle, check_close_cb); + r = uv_check_init(&check_handle); ASSERT(r == 0); r = uv_check_start(&check_handle, check_cb); ASSERT(r == 0); /* initialize only, prepare_2 is started by prepare_1_cb */ - r = uv_prepare_init(&prepare_2_handle, prepare_2_close_cb); + r = uv_prepare_init(&prepare_2_handle); ASSERT(r == 0); for (i = 0; i < IDLE_COUNT; i++) { /* initialize only, idle_1 handles are started by check_cb */ - r = uv_idle_init(&idle_1_handles[i], idle_1_close_cb); + r = uv_idle_init(&idle_1_handles[i]); ASSERT(r == 0); } @@ -343,7 +333,7 @@ TEST_IMPL(loop_handles) { /* the timer callback is there to keep the event loop polling */ /* unref it as it is not supposed to keep the loop alive */ - r = uv_timer_init(&timer_handle, timer_close_cb); + r = uv_timer_init(&timer_handle); ASSERT(r == 0); r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT); ASSERT(r == 0); @@ -389,7 +379,7 @@ TEST_IMPL(ref) { TEST_IMPL(idle_ref) { uv_idle_t h; uv_init(); - uv_idle_init(&h, NULL); + uv_idle_init(&h); uv_idle_start(&h, NULL); uv_unref(); uv_run(); @@ -400,7 +390,7 @@ TEST_IMPL(idle_ref) { TEST_IMPL(async_ref) { uv_async_t h; uv_init(); - uv_async_init(&h, NULL, NULL); + uv_async_init(&h, NULL); uv_unref(); uv_run(); return 0; @@ -410,7 +400,7 @@ TEST_IMPL(async_ref) { TEST_IMPL(prepare_ref) { uv_prepare_t h; uv_init(); - uv_prepare_init(&h, NULL); + uv_prepare_init(&h); uv_prepare_start(&h, NULL); uv_unref(); uv_run(); @@ -421,7 +411,7 @@ TEST_IMPL(prepare_ref) { TEST_IMPL(check_ref) { uv_check_t h; uv_init(); - uv_check_init(&h, NULL); + uv_check_init(&h); uv_check_start(&h, NULL); uv_unref(); uv_run(); diff --git a/test/test-ping-pong.c b/test/test-ping-pong.c index 97866f6f..8ed11289 100644 --- a/test/test-ping-pong.c +++ b/test/test-ping-pong.c @@ -56,10 +56,9 @@ static uv_buf_t alloc_cb(uv_tcp_t* tcp, size_t size) { } -static void pinger_on_close(uv_handle_t* handle, int status) { +static void pinger_on_close(uv_handle_t* handle) { pinger_t* pinger = (pinger_t*)handle->data; - ASSERT(status == 0); ASSERT(NUM_PINGS == pinger->pongs); free(pinger); @@ -108,7 +107,7 @@ static void pinger_read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { free(buf.base); } - uv_close((uv_handle_t*)(&pinger->tcp)); + uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close); return; } @@ -123,7 +122,7 @@ static void pinger_read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { if (pinger->pongs < NUM_PINGS) { pinger_write_ping(pinger); } else { - uv_close((uv_handle_t*)(&pinger->tcp)); + uv_close((uv_handle_t*)(&pinger->tcp), pinger_on_close); return; } } @@ -152,7 +151,7 @@ static void pinger_new() { pinger->pongs = 0; /* Try to connec to the server and do NUM_PINGS ping-pongs. */ - r = uv_tcp_init(&pinger->tcp, pinger_on_close); + r = uv_tcp_init(&pinger->tcp); pinger->tcp.data = pinger; ASSERT(!r); diff --git a/test/test-shutdown-eof.c b/test/test-shutdown-eof.c index eedfcd1d..71a1b906 100644 --- a/test/test-shutdown-eof.c +++ b/test/test-shutdown-eof.c @@ -102,7 +102,7 @@ static void connect_cb(uv_req_t *req, int status) { } -void tcp_close_cb(uv_handle_t* handle, int status) { +void tcp_close_cb(uv_handle_t* handle) { ASSERT(handle == (uv_handle_t*) &tcp); ASSERT(called_connect_cb == 1); @@ -114,7 +114,7 @@ void tcp_close_cb(uv_handle_t* handle, int status) { } -void timer_close_cb(uv_handle_t* handle, int status) { +void timer_close_cb(uv_handle_t* handle) { ASSERT(handle == (uv_handle_t*) &timer); called_timer_close_cb++; } @@ -122,14 +122,14 @@ void timer_close_cb(uv_handle_t* handle, int status) { void timer_cb(uv_handle_t* handle, int status) { ASSERT(handle == (uv_handle_t*) &timer); - uv_close(handle); + uv_close(handle, timer_close_cb); /* * The most important assert of the test: we have not received * tcp_close_cb yet. */ ASSERT(called_tcp_close_cb == 0); - uv_close((uv_handle_t*) &tcp); + uv_close((uv_handle_t*) &tcp, tcp_close_cb); called_timer_cb++; } @@ -150,11 +150,11 @@ TEST_IMPL(shutdown_eof) { qbuf.base = "Q"; qbuf.len = 1; - uv_timer_init(&timer, timer_close_cb); + uv_timer_init(&timer); uv_timer_start(&timer, timer_cb, 100, 0); server_addr = uv_ip4_addr("127.0.0.1", TEST_PORT); - r = uv_tcp_init(&tcp, tcp_close_cb); + r = uv_tcp_init(&tcp); ASSERT(!r); uv_req_init(&connect_req, (uv_handle_t*) &tcp, connect_cb); diff --git a/test/test-tcp-writealot.c b/test/test-tcp-writealot.c index 6c97a2f7..8548889e 100644 --- a/test/test-tcp-writealot.c +++ b/test/test-tcp-writealot.c @@ -53,9 +53,8 @@ static uv_buf_t alloc_cb(uv_tcp_t* tcp, size_t size) { } -static void close_cb(uv_handle_t* handle, int status) { +static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); - ASSERT(status == 0); free(handle); @@ -95,7 +94,7 @@ static void read_cb(uv_tcp_t* tcp, int nread, uv_buf_t buf) { free(buf.base); } - uv_close((uv_handle_t*)tcp); + uv_close((uv_handle_t*)tcp, close_cb); return; } @@ -182,7 +181,7 @@ TEST_IMPL(tcp_writealot) { uv_init(); - r = uv_tcp_init(client, close_cb); + r = uv_tcp_init(client); ASSERT(r == 0); uv_req_init(connect_req, (uv_handle_t*)client, connect_cb); diff --git a/test/test-timer-again.c b/test/test-timer-again.c index 904c563e..77482083 100644 --- a/test/test-timer-again.c +++ b/test/test-timer-again.c @@ -34,9 +34,8 @@ static uv_timer_t dummy, repeat_1, repeat_2; static int64_t start_time; -static void close_cb(uv_handle_t* handle, int status) { +static void close_cb(uv_handle_t* handle) { ASSERT(handle != NULL); - ASSERT(status == 0); close_cb_called++; } @@ -58,7 +57,7 @@ static void repeat_1_cb(uv_handle_t* handle, int status) { ASSERT(r == 0); if (uv_now() >= start_time + 500) { - uv_close(handle); + uv_close(handle, close_cb); /* We're not calling uv_timer_again on repeat_2 any more, so after this */ /* timer_2_cb is expected. */ repeat_2_cb_allowed = 1; @@ -78,7 +77,7 @@ static void repeat_2_cb(uv_handle_t* handle, int status) { if (uv_timer_get_repeat(&repeat_2) == 0) { ASSERT(!uv_is_active(handle)); - uv_close(handle); + uv_close(handle, close_cb); return; } @@ -100,7 +99,7 @@ TEST_IMPL(timer_again) { ASSERT(0 < start_time); /* Verify that it is not possible to uv_timer_again a never-started timer. */ - r = uv_timer_init(&dummy, NULL); + r = uv_timer_init(&dummy); ASSERT(r == 0); r = uv_timer_again(&dummy); ASSERT(r == -1); @@ -108,7 +107,7 @@ TEST_IMPL(timer_again) { uv_unref(); /* Start timer repeat_1. */ - r = uv_timer_init(&repeat_1, close_cb); + r = uv_timer_init(&repeat_1); ASSERT(r == 0); r = uv_timer_start(&repeat_1, repeat_1_cb, 50, 0); ASSERT(r == 0); @@ -122,7 +121,7 @@ TEST_IMPL(timer_again) { * Start another repeating timer. It'll be again()ed by the repeat_1 so * it should not time out until repeat_1 stops. */ - r = uv_timer_init(&repeat_2, close_cb); + r = uv_timer_init(&repeat_2); ASSERT(r == 0); r = uv_timer_start(&repeat_2, repeat_2_cb, 100, 100); ASSERT(r == 0); diff --git a/test/test-timer.c b/test/test-timer.c index 7b542e6b..5d39ad71 100644 --- a/test/test-timer.c +++ b/test/test-timer.c @@ -31,11 +31,10 @@ static int repeat_close_cb_called = 0; static int64_t start_time; -static void once_close_cb(uv_handle_t* handle, int status) { +static void once_close_cb(uv_handle_t* handle) { printf("ONCE_CLOSE_CB\n"); ASSERT(handle != NULL); - ASSERT(status == 0); once_close_cb_called++; @@ -51,18 +50,17 @@ static void once_cb(uv_handle_t* handle, int status) { once_cb_called++; - uv_close(handle); + uv_close(handle, once_close_cb); /* Just call this randomly for the code coverage. */ uv_update_time(); } -static void repeat_close_cb(uv_handle_t* handle, int status) { +static void repeat_close_cb(uv_handle_t* handle) { printf("REPEAT_CLOSE_CB\n"); ASSERT(handle != NULL); - ASSERT(status == 0); repeat_close_cb_called++; } @@ -77,16 +75,11 @@ static void repeat_cb(uv_handle_t* handle, int status) { repeat_cb_called++; if (repeat_cb_called == 5) { - uv_close(handle); + uv_close(handle, repeat_close_cb); } } -static void never_close_cb(uv_handle_t* handle, int status) { - FATAL("never_close_cb should never be called"); -} - - static void never_cb(uv_handle_t* handle, int status) { FATAL("never_cb should never be called"); } @@ -106,20 +99,20 @@ TEST_IMPL(timer) { for (i = 0; i < 10; i++) { once = (uv_timer_t*)malloc(sizeof(*once)); ASSERT(once != NULL); - r = uv_timer_init(once, once_close_cb); + r = uv_timer_init(once); ASSERT(r == 0); r = uv_timer_start(once, once_cb, i * 50, 0); ASSERT(r == 0); } /* The 11th timer is a repeating timer that runs 4 times */ - r = uv_timer_init(&repeat, repeat_close_cb); + r = uv_timer_init(&repeat); ASSERT(r == 0); r = uv_timer_start(&repeat, repeat_cb, 100, 100); ASSERT(r == 0); /* The 12th timer should not do anything. */ - r = uv_timer_init(&never, never_close_cb); + r = uv_timer_init(&never); ASSERT(r == 0); r = uv_timer_start(&never, never_cb, 100, 100); ASSERT(r == 0); diff --git a/uv-unix.c b/uv-unix.c index 8dd911b4..58b32279 100644 --- a/uv-unix.c +++ b/uv-unix.c @@ -132,11 +132,13 @@ struct sockaddr_in uv_ip4_addr(char* ip, int port) { } -int uv_close(uv_handle_t* handle) { +int uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_tcp_t* tcp; uv_async_t* async; uv_timer_t* timer; + handle->close_cb = close_cb; + switch (handle->type) { case UV_TCP: tcp = (uv_tcp_t*) handle; @@ -202,10 +204,8 @@ int uv_run() { } -static void uv__handle_init(uv_handle_t* handle, uv_handle_type type, - uv_close_cb close_cb) { +static void uv__handle_init(uv_handle_t* handle, uv_handle_type type) { handle->type = type; - handle->close_cb = close_cb; handle->flags = 0; ev_init(&handle->next_watcher, uv__next); @@ -216,8 +216,8 @@ static void uv__handle_init(uv_handle_t* handle, uv_handle_type type, } -int uv_tcp_init(uv_tcp_t* tcp, uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)tcp, UV_TCP, close_cb); +int uv_tcp_init(uv_tcp_t* tcp) { + uv__handle_init((uv_handle_t*)tcp, UV_TCP); tcp->alloc_cb = NULL; tcp->connect_req = NULL; @@ -362,12 +362,12 @@ void uv__server_io(EV_P_ ev_io* watcher, int revents) { } -int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb) { +int uv_accept(uv_tcp_t* server, uv_tcp_t* client) { if (server->accepted_fd < 0) { return -1; } - if (uv_tcp_init(client, close_cb)) { + if (uv_tcp_init(client)) { return -1; } @@ -467,7 +467,7 @@ void uv__finish_close(uv_handle_t* handle) { ev_idle_stop(EV_DEFAULT_ &handle->next_watcher); if (handle->close_cb) { - handle->close_cb(handle, 0); + handle->close_cb(handle); } ev_unref(EV_DEFAULT_UC); @@ -981,8 +981,8 @@ static void uv__prepare(EV_P_ ev_prepare* w, int revents) { } -int uv_prepare_init(uv_prepare_t* prepare, uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)prepare, UV_PREPARE, close_cb); +int uv_prepare_init(uv_prepare_t* prepare) { + uv__handle_init((uv_handle_t*)prepare, UV_PREPARE); ev_prepare_init(&prepare->prepare_watcher, uv__prepare); prepare->prepare_watcher.data = prepare; @@ -1030,8 +1030,8 @@ static void uv__check(EV_P_ ev_check* w, int revents) { } -int uv_check_init(uv_check_t* check, uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)check, UV_CHECK, close_cb); +int uv_check_init(uv_check_t* check) { + uv__handle_init((uv_handle_t*)check, UV_CHECK); ev_check_init(&check->check_watcher, uv__check); check->check_watcher.data = check; @@ -1080,8 +1080,8 @@ static void uv__idle(EV_P_ ev_idle* w, int revents) { -int uv_idle_init(uv_idle_t* idle, uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)idle, UV_IDLE, close_cb); +int uv_idle_init(uv_idle_t* idle) { + uv__handle_init((uv_handle_t*)idle, UV_IDLE); ev_idle_init(&idle->idle_watcher, uv__idle); idle->idle_watcher.data = idle; @@ -1148,9 +1148,8 @@ static void uv__async(EV_P_ ev_async* w, int revents) { } -int uv_async_init(uv_async_t* async, uv_async_cb async_cb, - uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)async, UV_ASYNC, close_cb); +int uv_async_init(uv_async_t* async, uv_async_cb async_cb) { + uv__handle_init((uv_handle_t*)async, UV_ASYNC); ev_async_init(&async->async_watcher, uv__async); async->async_watcher.data = async; @@ -1183,8 +1182,8 @@ static void uv__timer_cb(EV_P_ ev_timer* w, int revents) { } -int uv_timer_init(uv_timer_t* timer, uv_close_cb close_cb) { - uv__handle_init((uv_handle_t*)timer, UV_TIMER, close_cb); +int uv_timer_init(uv_timer_t* timer) { + uv__handle_init((uv_handle_t*)timer, UV_TIMER); ev_init(&timer->timer_watcher, uv__timer_cb); timer->timer_watcher.data = timer; diff --git a/uv-win.c b/uv-win.c index f853dc3c..80b5e4ee 100644 --- a/uv-win.c +++ b/uv-win.c @@ -455,12 +455,10 @@ static uv_req_t* uv_remove_pending_req() { } -static int uv_tcp_init_socket(uv_tcp_t* handle, uv_close_cb close_cb, - SOCKET socket) { +static int uv_tcp_init_socket(uv_tcp_t* handle, SOCKET socket) { DWORD yes = 1; handle->socket = socket; - handle->close_cb = close_cb; handle->write_queue_size = 0; handle->type = UV_TCP; handle->flags = 0; @@ -503,7 +501,7 @@ static void uv_tcp_init_connection(uv_tcp_t* handle) { } -int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb) { +int uv_tcp_init(uv_tcp_t* handle) { SOCKET sock; sock = socket(AF_INET, SOCK_STREAM, 0); @@ -512,7 +510,7 @@ int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb) { return -1; } - if (uv_tcp_init_socket(handle, close_cb, sock) == -1) { + if (uv_tcp_init_socket(handle, sock) == -1) { closesocket(sock); return -1; } @@ -552,8 +550,7 @@ static void uv_tcp_endgame(uv_tcp_t* handle) { handle->flags |= UV_HANDLE_CLOSED; if (handle->close_cb) { - uv_last_error_ = handle->error; - handle->close_cb((uv_handle_t*)handle, handle->error.code == UV_OK ? 0 : 1); + handle->close_cb((uv_handle_t*)handle); } uv_refs_--; @@ -567,7 +564,7 @@ static void uv_timer_endgame(uv_timer_t* handle) { handle->flags |= UV_HANDLE_CLOSED; if (handle->close_cb) { - handle->close_cb((uv_handle_t*)handle, 0); + handle->close_cb((uv_handle_t*)handle); } uv_refs_--; @@ -581,7 +578,7 @@ static void uv_loop_endgame(uv_handle_t* handle) { handle->flags |= UV_HANDLE_CLOSED; if (handle->close_cb) { - handle->close_cb(handle, 0); + handle->close_cb(handle); } uv_refs_--; @@ -596,7 +593,7 @@ static void uv_async_endgame(uv_async_t* handle) { handle->flags |= UV_HANDLE_CLOSED; if (handle->close_cb) { - handle->close_cb((uv_handle_t*)handle, 0); + handle->close_cb((uv_handle_t*)handle); } uv_refs_--; @@ -704,7 +701,8 @@ static int uv_close_error(uv_handle_t* handle, uv_err_t e) { } -int uv_close(uv_handle_t* handle) { +int uv_close(uv_handle_t* handle, uv_close_cb close_cb) { + handle->close_cb = close_cb; return uv_close_error(handle, uv_ok_); } @@ -867,7 +865,7 @@ int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { } -int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb) { +int uv_accept(uv_tcp_t* server, uv_tcp_t* client) { int rv = 0; if (server->accept_socket == INVALID_SOCKET) { @@ -875,7 +873,7 @@ int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb) { return -1; } - if (uv_tcp_init_socket(client, close_cb, server->accept_socket) == -1) { + if (uv_tcp_init_socket(client, server->accept_socket) == -1) { closesocket(server->accept_socket); rv = -1; } @@ -1237,9 +1235,8 @@ static int uv_timer_compare(uv_timer_t* a, uv_timer_t* b) { RB_GENERATE_STATIC(uv_timer_tree_s, uv_timer_s, tree_entry, uv_timer_compare); -int uv_timer_init(uv_timer_t* handle, uv_close_cb close_cb) { +int uv_timer_init(uv_timer_t* handle) { handle->type = UV_TIMER; - handle->close_cb = (void*) close_cb; handle->flags = 0; handle->error = uv_ok_; handle->timer_cb = NULL; @@ -1334,8 +1331,7 @@ int64_t uv_now() { } -int uv_loop_init(uv_handle_t* handle, uv_close_cb close_cb) { - handle->close_cb = (void*) close_cb; +int uv_loop_init(uv_handle_t* handle) { handle->flags = 0; handle->error = uv_ok_; @@ -1411,21 +1407,21 @@ static void uv_loop_invoke(uv_handle_t* list) { } -int uv_prepare_init(uv_prepare_t* handle, uv_close_cb close_cb) { +int uv_prepare_init(uv_prepare_t* handle) { handle->type = UV_PREPARE; - return uv_loop_init((uv_handle_t*)handle, close_cb); + return uv_loop_init((uv_handle_t*)handle); } -int uv_check_init(uv_check_t* handle, uv_close_cb close_cb) { +int uv_check_init(uv_check_t* handle) { handle->type = UV_CHECK; - return uv_loop_init((uv_handle_t*)handle, close_cb); + return uv_loop_init((uv_handle_t*)handle); } -int uv_idle_init(uv_idle_t* handle, uv_close_cb close_cb) { +int uv_idle_init(uv_idle_t* handle) { handle->type = UV_IDLE; - return uv_loop_init((uv_handle_t*)handle, close_cb); + return uv_loop_init((uv_handle_t*)handle); } @@ -1479,12 +1475,10 @@ int uv_is_active(uv_handle_t* handle) { } -int uv_async_init(uv_async_t* handle, uv_async_cb async_cb, - uv_close_cb close_cb) { +int uv_async_init(uv_async_t* handle, uv_async_cb async_cb) { uv_req_t* req; handle->type = UV_ASYNC; - handle->close_cb = (void*) close_cb; handle->flags = 0; handle->async_sent = 0; handle->error = uv_ok_; diff --git a/uv.h b/uv.h index b58a9d4b..4650f469 100644 --- a/uv.h +++ b/uv.h @@ -62,7 +62,7 @@ typedef void (*uv_write_cb)(uv_req_t* req, int status); typedef void (*uv_connect_cb)(uv_req_t* req, int status); typedef void (*uv_shutdown_cb)(uv_req_t* req, int status); typedef void (*uv_connection_cb)(uv_tcp_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle, int status); +typedef void (*uv_close_cb)(uv_handle_t* handle); /* TODO: do loop_cb and async_cb really need a status argument? */ typedef void (*uv_loop_cb)(uv_handle_t* handle, int status); typedef void (*uv_async_cb)(uv_handle_t* handle, int stats); @@ -180,7 +180,7 @@ int uv_is_active(uv_handle_t* handle); * Request handle to be closed. close_cb will be called asynchronously after * this call. This MUST be called on each handle before memory is released. */ -int uv_close(uv_handle_t* handle); +int uv_close(uv_handle_t* handle, uv_close_cb close_cb); /* @@ -194,7 +194,7 @@ struct uv_tcp_s { UV_TCP_PRIVATE_FIELDS }; -int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb); +int uv_tcp_init(uv_tcp_t* handle); int uv_bind(uv_tcp_t* handle, struct sockaddr_in); @@ -205,7 +205,7 @@ int uv_shutdown(uv_req_t* req); int uv_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb); /* Call this after connection_cb. client does not need to be initialized. */ -int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb); +int uv_accept(uv_tcp_t* server, uv_tcp_t* client); /* Read data from an incoming stream. The callback will be made several * several times until there is no more data to read or uv_read_stop is @@ -233,7 +233,7 @@ struct uv_prepare_s { UV_PREPARE_PRIVATE_FIELDS }; -int uv_prepare_init(uv_prepare_t* prepare, uv_close_cb close_cb); +int uv_prepare_init(uv_prepare_t* prepare); int uv_prepare_start(uv_prepare_t* prepare, uv_loop_cb cb); @@ -250,7 +250,7 @@ struct uv_check_s { UV_CHECK_PRIVATE_FIELDS }; -int uv_check_init(uv_check_t* check, uv_close_cb close_cb); +int uv_check_init(uv_check_t* check); int uv_check_start(uv_check_t* check, uv_loop_cb cb); @@ -268,7 +268,7 @@ struct uv_idle_s { UV_IDLE_PRIVATE_FIELDS }; -int uv_idle_init(uv_idle_t* idle, uv_close_cb close_cb); +int uv_idle_init(uv_idle_t* idle); int uv_idle_start(uv_idle_t* idle, uv_loop_cb cb); @@ -288,8 +288,7 @@ typedef struct { UV_ASYNC_PRIVATE_FIELDS } uv_async_t; -int uv_async_init(uv_async_t* async, uv_async_cb async_cb, - uv_close_cb close_cb); +int uv_async_init(uv_async_t* async, uv_async_cb async_cb); int uv_async_send(uv_async_t* async); @@ -303,7 +302,7 @@ struct uv_timer_s { UV_TIMER_PRIVATE_FIELDS }; -int uv_timer_init(uv_timer_t* timer, uv_close_cb close_cb); +int uv_timer_init(uv_timer_t* timer); int uv_timer_start(uv_timer_t* timer, uv_loop_cb cb, int64_t timeout, int64_t repeat);