diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-08-31 01:53:01 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-08-31 01:53:30 -0700 |
commit | 21cc4c4985fdf40cc128cd88cfdc02fd49e33b26 (patch) | |
tree | fbda524d1b1a9f12b6b271574ac3383d27eacb7e /deps/uv/test/echo-server.c | |
parent | 6f606838025c4e87701f360135f1ae72e968dc4c (diff) | |
download | android-node-v8-21cc4c4985fdf40cc128cd88cfdc02fd49e33b26.tar.gz android-node-v8-21cc4c4985fdf40cc128cd88cfdc02fd49e33b26.tar.bz2 android-node-v8-21cc4c4985fdf40cc128cd88cfdc02fd49e33b26.zip |
Upgrade libuv to ea4271f
Required adding uv_default_loop() in many places.
Diffstat (limited to 'deps/uv/test/echo-server.c')
-rw-r--r-- | deps/uv/test/echo-server.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/deps/uv/test/echo-server.c b/deps/uv/test/echo-server.c index 270af3787a..ba8a912e36 100644 --- a/deps/uv/test/echo-server.c +++ b/deps/uv/test/echo-server.c @@ -29,6 +29,8 @@ typedef struct { uv_buf_t buf; } write_req_t; +static uv_loop_t* loop; + static int server_closed; static stream_type serverType; static uv_tcp_t tcpServer; @@ -46,7 +48,7 @@ static void after_write(uv_write_t* req, int status) { write_req_t* wr; if (status) { - uv_err_t err = uv_last_error(); + uv_err_t err = uv_last_error(loop); fprintf(stderr, "uv_write error: %s\n", uv_strerror(err)); ASSERT(0); } @@ -72,7 +74,7 @@ static void after_read(uv_stream_t* handle, ssize_t nread, uv_buf_t buf) { if (nread < 0) { /* Error or EOF */ - ASSERT (uv_last_error().code == UV_EOF); + ASSERT (uv_last_error(loop).code == UV_EOF); if (buf.base) { free(buf.base); @@ -133,7 +135,8 @@ static void on_connection(uv_stream_t* server, int status) { int r; if (status != 0) { - fprintf(stderr, "Connect error %d\n", uv_last_error().code); + fprintf(stderr, "Connect error %d\n", + uv_last_error(loop).code); } ASSERT(status == 0); @@ -141,13 +144,13 @@ static void on_connection(uv_stream_t* server, int status) { case TCP: stream = malloc(sizeof(uv_tcp_t)); ASSERT(stream != NULL); - uv_tcp_init((uv_tcp_t*)stream); + uv_tcp_init(loop, (uv_tcp_t*)stream); break; case PIPE: stream = malloc(sizeof(uv_pipe_t)); ASSERT(stream != NULL); - uv_pipe_init((uv_pipe_t*)stream); + uv_pipe_init(loop, (uv_pipe_t*)stream); break; default: @@ -178,7 +181,7 @@ static int tcp4_echo_start(int port) { server = (uv_handle_t*)&tcpServer; serverType = TCP; - r = uv_tcp_init(&tcpServer); + r = uv_tcp_init(loop, &tcpServer); if (r) { /* TODO: Error codes */ fprintf(stderr, "Socket creation error\n"); @@ -195,7 +198,8 @@ static int tcp4_echo_start(int port) { r = uv_listen((uv_stream_t*)&tcpServer, SOMAXCONN, on_connection); if (r) { /* TODO: Error codes */ - fprintf(stderr, "Listen error %s\n", uv_err_name(uv_last_error())); + fprintf(stderr, "Listen error %s\n", + uv_err_name(uv_last_error(loop))); return 1; } @@ -210,7 +214,7 @@ static int tcp6_echo_start(int port) { server = (uv_handle_t*)&tcpServer; serverType = TCP; - r = uv_tcp_init(&tcpServer); + r = uv_tcp_init(loop, &tcpServer); if (r) { /* TODO: Error codes */ fprintf(stderr, "Socket creation error\n"); @@ -242,21 +246,24 @@ static int pipe_echo_start(char* pipeName) { server = (uv_handle_t*)&pipeServer; serverType = PIPE; - r = uv_pipe_init(&pipeServer); + r = uv_pipe_init(loop, &pipeServer); if (r) { - fprintf(stderr, "uv_pipe_init: %s\n", uv_strerror(uv_last_error())); + fprintf(stderr, "uv_pipe_init: %s\n", + uv_strerror(uv_last_error(loop))); return 1; } r = uv_pipe_bind(&pipeServer, pipeName); if (r) { - fprintf(stderr, "uv_pipe_bind: %s\n", uv_strerror(uv_last_error())); + fprintf(stderr, "uv_pipe_bind: %s\n", + uv_strerror(uv_last_error(loop))); return 1; } r = uv_listen((uv_stream_t*)&pipeServer, SOMAXCONN, on_connection); if (r) { - fprintf(stderr, "uv_pipe_listen: %s\n", uv_strerror(uv_last_error())); + fprintf(stderr, "uv_pipe_listen: %s\n", + uv_strerror(uv_last_error(loop))); return 1; } @@ -266,30 +273,35 @@ static int pipe_echo_start(char* pipeName) { HELPER_IMPL(tcp4_echo_server) { uv_init(); + loop = uv_default_loop(); + if (tcp4_echo_start(TEST_PORT)) return 1; - uv_run(); + uv_run(loop); return 0; } HELPER_IMPL(tcp6_echo_server) { uv_init(); + loop = uv_default_loop(); + if (tcp6_echo_start(TEST_PORT)) return 1; - uv_run(); + uv_run(loop); return 0; } HELPER_IMPL(pipe_echo_server) { uv_init(); + loop = uv_default_loop(); if (pipe_echo_start(TEST_PIPENAME)) return 1; - uv_run(); + uv_run(loop); return 0; } |