API Change: Remove data parameters from init functions
This commit is contained in:
parent
e58a1abff0
commit
7db9629f87
@ -49,8 +49,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,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Accepts a connection. This should be called after the accept callback is
|
||||
made. The `client` parameter should be uninitialized memory; `uv_accept` is
|
||||
@ -92,8 +91,7 @@ Stops reading from the stream.
|
||||
uv_stream_t*,
|
||||
uv_buf_t bufs[],
|
||||
int butcnf,
|
||||
uv_close_cb close_cb,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Initiates a write request on a stream.
|
||||
|
||||
@ -113,8 +111,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,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Initiates a request to open a connection.
|
||||
|
||||
@ -134,8 +131,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,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Initializes the connection request. Returning 0 indicates success, -1 if
|
||||
there was an error. The following values can be retrieved from
|
||||
@ -153,8 +149,7 @@ stream will allow no more writes.
|
||||
|
||||
int uv_shutdown_req_init(uv_shutdown_req_t*,
|
||||
uv_stream_t* parent,
|
||||
uv_close_cb close_cb,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Initializes the shutdown request.
|
||||
|
||||
@ -165,7 +160,6 @@ Initializes the shutdown request.
|
||||
uv_stream_t*,
|
||||
uv_buf_t bufs[],
|
||||
int butcnf,
|
||||
uv_close_cb close_cb,
|
||||
void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
Initiates a write request on a stream.
|
||||
|
||||
@ -190,9 +190,11 @@ 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, (void*)pinger);
|
||||
r = uv_tcp_init(&pinger->tcp, pinger_close_cb);
|
||||
ASSERT(!r);
|
||||
|
||||
pinger->tcp.data = pinger;
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
/* so these handles can be pre-initialized. */
|
||||
uv_req_init(&pinger->connect_req, (uv_handle_t*)&pinger->tcp,
|
||||
|
||||
@ -147,7 +147,7 @@ static void start_stats_collection() {
|
||||
|
||||
/* Show-stats timer */
|
||||
stats_left = STATS_COUNT;
|
||||
r = uv_timer_init(&timer_handle, NULL, NULL);
|
||||
r = uv_timer_init(&timer_handle, NULL);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&timer_handle, show_stats, STATS_INTERVAL, STATS_INTERVAL);
|
||||
ASSERT(r == 0);
|
||||
@ -239,7 +239,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, NULL);
|
||||
r = uv_tcp_init(tcp, write_sockets_close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
req = req_alloc();
|
||||
@ -259,7 +259,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, NULL);
|
||||
r = uv_accept(s, tcp, read_sockets_close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_read_start(tcp, buf_alloc, read_cb);
|
||||
@ -350,7 +350,7 @@ HELPER_IMPL(pump_server) {
|
||||
listen_addr = uv_ip4_addr("0.0.0.0", TEST_PORT);
|
||||
|
||||
/* Server */
|
||||
r = uv_tcp_init(&server, NULL, NULL);
|
||||
r = uv_tcp_init(&server, NULL);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, listen_addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -135,7 +135,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, NULL);
|
||||
r = uv_accept(server, handle, on_close);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_read_start(handle, echo_alloc, after_read);
|
||||
@ -153,7 +153,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, NULL);
|
||||
r = uv_tcp_init(&server, on_server_close);
|
||||
if (r) {
|
||||
/* TODO: Error codes */
|
||||
fprintf(stderr, "Socket creation error\n");
|
||||
|
||||
@ -191,12 +191,12 @@ TEST_IMPL(async) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_prepare_init(&prepare_handle, close_cb, NULL);
|
||||
r = uv_prepare_init(&prepare_handle, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_prepare_start(&prepare_handle, prepare_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_async_init(&async1_handle, async1_cb, close_cb, NULL);
|
||||
r = uv_async_init(&async1_handle, async1_cb, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
#if 0
|
||||
|
||||
@ -43,12 +43,12 @@ TEST_IMPL(bind_error_addrinuse) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(&server1, close_cb, NULL);
|
||||
r = uv_tcp_init(&server1, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server1, addr);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_tcp_init(&server2, close_cb, NULL);
|
||||
r = uv_tcp_init(&server2, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server2, addr);
|
||||
ASSERT(r == 0);
|
||||
@ -78,7 +78,7 @@ TEST_IMPL(bind_error_addrnotavail_1) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(&server, close_cb, NULL);
|
||||
r = uv_tcp_init(&server, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, addr);
|
||||
|
||||
@ -104,7 +104,7 @@ TEST_IMPL(bind_error_addrnotavail_2) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(&server, close_cb, NULL);
|
||||
r = uv_tcp_init(&server, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, addr);
|
||||
ASSERT(r == -1);
|
||||
@ -130,7 +130,7 @@ TEST_IMPL(bind_error_fault) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(&server, close_cb, NULL);
|
||||
r = uv_tcp_init(&server, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, *garbage_addr);
|
||||
ASSERT(r == -1);
|
||||
@ -156,7 +156,7 @@ TEST_IMPL(bind_error_inval) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(&server, close_cb, NULL);
|
||||
r = uv_tcp_init(&server, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_bind(&server, addr1);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -145,7 +145,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, NULL);
|
||||
r = uv_timer_init(&timer, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&timer, timer_cb, 500, 0);
|
||||
ASSERT(r == 0);
|
||||
@ -185,7 +185,7 @@ TEST_IMPL(callback_stack) {
|
||||
|
||||
uv_init();
|
||||
|
||||
if (uv_tcp_init(&client, &close_cb, NULL)) {
|
||||
if (uv_tcp_init(&client, &close_cb)) {
|
||||
FATAL("uv_tcp_init failed");
|
||||
}
|
||||
|
||||
|
||||
@ -99,7 +99,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, NULL);
|
||||
r = uv_tcp_init(&tcp, on_close);
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
@ -141,7 +141,7 @@ TEST_IMPL(connection_fail) {
|
||||
TEST_IMPL(connection_fail_doesnt_auto_close) {
|
||||
uv_init();
|
||||
|
||||
uv_timer_init(&timer, timer_close_cb, NULL);
|
||||
uv_timer_init(&timer, timer_close_cb);
|
||||
|
||||
connection_fail(on_connect_without_close);
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ 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, NULL);
|
||||
r = uv_accept(server, accepted_handle, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
do_accept_called++;
|
||||
@ -92,8 +92,11 @@ 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, (void*)tcp);
|
||||
r = uv_timer_init(timer_handle, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
timer_handle->data = tcp;
|
||||
|
||||
r = uv_timer_start(timer_handle, do_accept, 1000, 0);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -108,7 +111,7 @@ static void start_server() {
|
||||
|
||||
ASSERT(server != NULL);
|
||||
|
||||
r = uv_tcp_init(server, close_cb, NULL);
|
||||
r = uv_tcp_init(server, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
r = uv_bind(server, addr);
|
||||
@ -159,7 +162,7 @@ static void client_connect() {
|
||||
ASSERT(client != NULL);
|
||||
ASSERT(connect_req != NULL);
|
||||
|
||||
r = uv_tcp_init(client, close_cb, NULL);
|
||||
r = uv_tcp_init(client, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
uv_req_init(connect_req, (uv_handle_t*)client, connect_cb);
|
||||
|
||||
@ -162,7 +162,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, NULL);
|
||||
r = uv_idle_init(&idle_2_handle, idle_2_close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_idle_start(&idle_2_handle, idle_2_cb);
|
||||
ASSERT(r == 0);
|
||||
@ -319,23 +319,23 @@ TEST_IMPL(loop_handles) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_prepare_init(&prepare_1_handle, prepare_1_close_cb, NULL);
|
||||
r = uv_prepare_init(&prepare_1_handle, prepare_1_close_cb);
|
||||
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, NULL);
|
||||
r = uv_check_init(&check_handle, check_close_cb);
|
||||
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, NULL);
|
||||
r = uv_prepare_init(&prepare_2_handle, prepare_2_close_cb);
|
||||
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, NULL);
|
||||
r = uv_idle_init(&idle_1_handles[i], idle_1_close_cb);
|
||||
ASSERT(r == 0);
|
||||
}
|
||||
|
||||
@ -343,7 +343,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, NULL);
|
||||
r = uv_timer_init(&timer_handle, timer_close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&timer_handle, timer_cb, TIMEOUT, TIMEOUT);
|
||||
ASSERT(r == 0);
|
||||
@ -389,7 +389,7 @@ TEST_IMPL(ref) {
|
||||
TEST_IMPL(idle_ref) {
|
||||
uv_idle_t h;
|
||||
uv_init();
|
||||
uv_idle_init(&h, NULL, NULL);
|
||||
uv_idle_init(&h, NULL);
|
||||
uv_idle_start(&h, NULL);
|
||||
uv_unref();
|
||||
uv_run();
|
||||
@ -400,7 +400,7 @@ TEST_IMPL(idle_ref) {
|
||||
TEST_IMPL(async_ref) {
|
||||
uv_async_t h;
|
||||
uv_init();
|
||||
uv_async_init(&h, NULL, NULL, NULL);
|
||||
uv_async_init(&h, NULL, NULL);
|
||||
uv_unref();
|
||||
uv_run();
|
||||
return 0;
|
||||
@ -410,7 +410,7 @@ TEST_IMPL(async_ref) {
|
||||
TEST_IMPL(prepare_ref) {
|
||||
uv_prepare_t h;
|
||||
uv_init();
|
||||
uv_prepare_init(&h, NULL, NULL);
|
||||
uv_prepare_init(&h, NULL);
|
||||
uv_prepare_start(&h, NULL);
|
||||
uv_unref();
|
||||
uv_run();
|
||||
@ -421,7 +421,7 @@ TEST_IMPL(prepare_ref) {
|
||||
TEST_IMPL(check_ref) {
|
||||
uv_check_t h;
|
||||
uv_init();
|
||||
uv_check_init(&h, NULL, NULL);
|
||||
uv_check_init(&h, NULL);
|
||||
uv_check_start(&h, NULL);
|
||||
uv_unref();
|
||||
uv_run();
|
||||
|
||||
@ -152,7 +152,8 @@ 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, (void*)pinger);
|
||||
r = uv_tcp_init(&pinger->tcp, pinger_on_close);
|
||||
pinger->tcp.data = pinger;
|
||||
ASSERT(!r);
|
||||
|
||||
/* We are never doing multiple reads/connects at a time anyway. */
|
||||
|
||||
@ -150,11 +150,11 @@ TEST_IMPL(shutdown_eof) {
|
||||
qbuf.base = "Q";
|
||||
qbuf.len = 1;
|
||||
|
||||
uv_timer_init(&timer, timer_close_cb, NULL);
|
||||
uv_timer_init(&timer, timer_close_cb);
|
||||
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, NULL);
|
||||
r = uv_tcp_init(&tcp, tcp_close_cb);
|
||||
ASSERT(!r);
|
||||
|
||||
uv_req_init(&connect_req, (uv_handle_t*) &tcp, connect_cb);
|
||||
|
||||
@ -182,7 +182,7 @@ TEST_IMPL(tcp_writealot) {
|
||||
|
||||
uv_init();
|
||||
|
||||
r = uv_tcp_init(client, close_cb, NULL);
|
||||
r = uv_tcp_init(client, close_cb);
|
||||
ASSERT(r == 0);
|
||||
|
||||
uv_req_init(connect_req, (uv_handle_t*)client, connect_cb);
|
||||
|
||||
@ -100,7 +100,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, NULL);
|
||||
r = uv_timer_init(&dummy, NULL);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_again(&dummy);
|
||||
ASSERT(r == -1);
|
||||
@ -108,7 +108,7 @@ TEST_IMPL(timer_again) {
|
||||
uv_unref();
|
||||
|
||||
/* Start timer repeat_1. */
|
||||
r = uv_timer_init(&repeat_1, close_cb, NULL);
|
||||
r = uv_timer_init(&repeat_1, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&repeat_1, repeat_1_cb, 50, 0);
|
||||
ASSERT(r == 0);
|
||||
@ -122,7 +122,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, NULL);
|
||||
r = uv_timer_init(&repeat_2, close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&repeat_2, repeat_2_cb, 100, 100);
|
||||
ASSERT(r == 0);
|
||||
|
||||
@ -106,20 +106,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, NULL);
|
||||
r = uv_timer_init(once, once_close_cb);
|
||||
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, NULL);
|
||||
r = uv_timer_init(&repeat, repeat_close_cb);
|
||||
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, NULL);
|
||||
r = uv_timer_init(&never, never_close_cb);
|
||||
ASSERT(r == 0);
|
||||
r = uv_timer_start(&never, never_cb, 100, 100);
|
||||
ASSERT(r == 0);
|
||||
|
||||
32
uv-unix.c
32
uv-unix.c
@ -203,10 +203,9 @@ int uv_run() {
|
||||
|
||||
|
||||
static void uv__handle_init(uv_handle_t* handle, uv_handle_type type,
|
||||
uv_close_cb close_cb, void* data) {
|
||||
uv_close_cb close_cb) {
|
||||
handle->type = type;
|
||||
handle->close_cb = close_cb;
|
||||
handle->data = data;
|
||||
handle->flags = 0;
|
||||
|
||||
ev_init(&handle->next_watcher, uv__next);
|
||||
@ -217,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)tcp, UV_TCP, close_cb, data);
|
||||
int uv_tcp_init(uv_tcp_t* tcp, uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)tcp, UV_TCP, close_cb);
|
||||
|
||||
tcp->alloc_cb = NULL;
|
||||
tcp->connect_req = NULL;
|
||||
@ -363,13 +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, void* data) {
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb) {
|
||||
if (server->accepted_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uv_tcp_init(client, close_cb, data)) {
|
||||
if (uv_tcp_init(client, close_cb)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -983,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)prepare, UV_PREPARE, close_cb, data);
|
||||
int uv_prepare_init(uv_prepare_t* prepare, uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)prepare, UV_PREPARE, close_cb);
|
||||
|
||||
ev_prepare_init(&prepare->prepare_watcher, uv__prepare);
|
||||
prepare->prepare_watcher.data = prepare;
|
||||
@ -1032,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)check, UV_CHECK, close_cb, data);
|
||||
int uv_check_init(uv_check_t* check, uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)check, UV_CHECK, close_cb);
|
||||
|
||||
ev_check_init(&check->check_watcher, uv__check);
|
||||
check->check_watcher.data = check;
|
||||
@ -1082,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)idle, UV_IDLE, close_cb, data);
|
||||
int uv_idle_init(uv_idle_t* idle, uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)idle, UV_IDLE, close_cb);
|
||||
|
||||
ev_idle_init(&idle->idle_watcher, uv__idle);
|
||||
idle->idle_watcher.data = idle;
|
||||
@ -1151,8 +1149,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)async, UV_ASYNC, close_cb, data);
|
||||
uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)async, UV_ASYNC, close_cb);
|
||||
|
||||
ev_async_init(&async->async_watcher, uv__async);
|
||||
async->async_watcher.data = async;
|
||||
@ -1185,8 +1183,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, void* data) {
|
||||
uv__handle_init((uv_handle_t*)timer, UV_TIMER, close_cb, data);
|
||||
int uv_timer_init(uv_timer_t* timer, uv_close_cb close_cb) {
|
||||
uv__handle_init((uv_handle_t*)timer, UV_TIMER, close_cb);
|
||||
|
||||
ev_init(&timer->timer_watcher, uv__timer_cb);
|
||||
timer->timer_watcher.data = timer;
|
||||
|
||||
33
uv-win.c
33
uv-win.c
@ -456,12 +456,11 @@ static uv_req_t* uv_remove_pending_req() {
|
||||
|
||||
|
||||
static int uv_tcp_init_socket(uv_tcp_t* handle, uv_close_cb close_cb,
|
||||
void* data, SOCKET socket) {
|
||||
SOCKET socket) {
|
||||
DWORD yes = 1;
|
||||
|
||||
handle->socket = socket;
|
||||
handle->close_cb = close_cb;
|
||||
handle->data = data;
|
||||
handle->write_queue_size = 0;
|
||||
handle->type = UV_TCP;
|
||||
handle->flags = 0;
|
||||
@ -504,7 +503,7 @@ static void uv_tcp_init_connection(uv_tcp_t* handle) {
|
||||
}
|
||||
|
||||
|
||||
int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb, void* data) {
|
||||
int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb) {
|
||||
SOCKET sock;
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@ -513,7 +512,7 @@ int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb, void* data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uv_tcp_init_socket(handle, close_cb, data, sock) == -1) {
|
||||
if (uv_tcp_init_socket(handle, close_cb, sock) == -1) {
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
@ -868,8 +867,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, void* data) {
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb) {
|
||||
int rv = 0;
|
||||
|
||||
if (server->accept_socket == INVALID_SOCKET) {
|
||||
@ -877,7 +875,7 @@ int uv_accept(uv_tcp_t* server, uv_tcp_t* client,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (uv_tcp_init_socket(client, close_cb, data, server->accept_socket) == -1) {
|
||||
if (uv_tcp_init_socket(client, close_cb, server->accept_socket) == -1) {
|
||||
closesocket(server->accept_socket);
|
||||
rv = -1;
|
||||
}
|
||||
@ -1239,10 +1237,9 @@ 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, void* data) {
|
||||
int uv_timer_init(uv_timer_t* handle, uv_close_cb close_cb) {
|
||||
handle->type = UV_TIMER;
|
||||
handle->close_cb = (void*) close_cb;
|
||||
handle->data = data;
|
||||
handle->flags = 0;
|
||||
handle->error = uv_ok_;
|
||||
handle->timer_cb = NULL;
|
||||
@ -1337,9 +1334,8 @@ int64_t uv_now() {
|
||||
}
|
||||
|
||||
|
||||
int uv_loop_init(uv_handle_t* handle, uv_close_cb close_cb, void* data) {
|
||||
int uv_loop_init(uv_handle_t* handle, uv_close_cb close_cb) {
|
||||
handle->close_cb = (void*) close_cb;
|
||||
handle->data = data;
|
||||
handle->flags = 0;
|
||||
handle->error = uv_ok_;
|
||||
|
||||
@ -1415,21 +1411,21 @@ static void uv_loop_invoke(uv_handle_t* list) {
|
||||
}
|
||||
|
||||
|
||||
int uv_prepare_init(uv_prepare_t* handle, uv_close_cb close_cb, void* data) {
|
||||
int uv_prepare_init(uv_prepare_t* handle, uv_close_cb close_cb) {
|
||||
handle->type = UV_PREPARE;
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb, data);
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb);
|
||||
}
|
||||
|
||||
|
||||
int uv_check_init(uv_check_t* handle, uv_close_cb close_cb, void* data) {
|
||||
int uv_check_init(uv_check_t* handle, uv_close_cb close_cb) {
|
||||
handle->type = UV_CHECK;
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb, data);
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb);
|
||||
}
|
||||
|
||||
|
||||
int uv_idle_init(uv_idle_t* handle, uv_close_cb close_cb, void* data) {
|
||||
int uv_idle_init(uv_idle_t* handle, uv_close_cb close_cb) {
|
||||
handle->type = UV_IDLE;
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb, data);
|
||||
return uv_loop_init((uv_handle_t*)handle, close_cb);
|
||||
}
|
||||
|
||||
|
||||
@ -1484,12 +1480,11 @@ 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, void* data) {
|
||||
uv_close_cb close_cb) {
|
||||
uv_req_t* req;
|
||||
|
||||
handle->type = UV_ASYNC;
|
||||
handle->close_cb = (void*) close_cb;
|
||||
handle->data = data;
|
||||
handle->flags = 0;
|
||||
handle->async_sent = 0;
|
||||
handle->error = uv_ok_;
|
||||
|
||||
15
uv.h
15
uv.h
@ -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, void* data);
|
||||
int uv_tcp_init(uv_tcp_t* handle, uv_close_cb close_cb);
|
||||
|
||||
int uv_bind(uv_tcp_t* handle, struct sockaddr_in);
|
||||
|
||||
@ -205,8 +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, void* data);
|
||||
int uv_accept(uv_tcp_t* server, uv_tcp_t* client, uv_close_cb close_cb);
|
||||
|
||||
/* 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
|
||||
@ -234,7 +233,7 @@ struct uv_prepare_s {
|
||||
UV_PREPARE_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
int uv_prepare_init(uv_prepare_t* prepare, uv_close_cb close_cb, void* data);
|
||||
int uv_prepare_init(uv_prepare_t* prepare, uv_close_cb close_cb);
|
||||
|
||||
int uv_prepare_start(uv_prepare_t* prepare, uv_loop_cb cb);
|
||||
|
||||
@ -251,7 +250,7 @@ struct uv_check_s {
|
||||
UV_CHECK_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
int uv_check_init(uv_check_t* check, uv_close_cb close_cb, void* data);
|
||||
int uv_check_init(uv_check_t* check, uv_close_cb close_cb);
|
||||
|
||||
int uv_check_start(uv_check_t* check, uv_loop_cb cb);
|
||||
|
||||
@ -269,7 +268,7 @@ struct uv_idle_s {
|
||||
UV_IDLE_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
int uv_idle_init(uv_idle_t* idle, uv_close_cb close_cb, void* data);
|
||||
int uv_idle_init(uv_idle_t* idle, uv_close_cb close_cb);
|
||||
|
||||
int uv_idle_start(uv_idle_t* idle, uv_loop_cb cb);
|
||||
|
||||
@ -290,7 +289,7 @@ typedef struct {
|
||||
} uv_async_t;
|
||||
|
||||
int uv_async_init(uv_async_t* async, uv_async_cb async_cb,
|
||||
uv_close_cb close_cb, void* data);
|
||||
uv_close_cb close_cb);
|
||||
|
||||
int uv_async_send(uv_async_t* async);
|
||||
|
||||
@ -304,7 +303,7 @@ struct uv_timer_s {
|
||||
UV_TIMER_PRIVATE_FIELDS
|
||||
};
|
||||
|
||||
int uv_timer_init(uv_timer_t* timer, uv_close_cb close_cb, void* data);
|
||||
int uv_timer_init(uv_timer_t* timer, uv_close_cb close_cb);
|
||||
|
||||
int uv_timer_start(uv_timer_t* timer, uv_loop_cb cb, int64_t timeout, int64_t repeat);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user