From 9603f08f21987d5367d98267a16179a61e4400c1 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 30 Aug 2012 17:28:02 +0200 Subject: [PATCH] uv: upgrade to 24c062c --- deps/uv/include/uv.h | 5 +++-- deps/uv/src/unix/error.c | 1 + deps/uv/src/unix/udp.c | 5 +++++ deps/uv/src/win/core.c | 3 +++ deps/uv/src/win/tcp.c | 14 +++++++++++++- 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 7c2c03f928..49160b2bc2 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -120,8 +120,9 @@ extern "C" { XX( 53, ENOTEMPTY, "directory not empty") \ XX( 54, ENOSPC, "no space left on device") \ XX( 55, EIO, "i/o error") \ - XX( 56, EROFS, "read-only file system" ) \ - XX( 57, ENODEV, "no such device" ) + XX( 56, EROFS, "read-only file system") \ + XX( 57, ENODEV, "no such device") \ + XX( 58, ESPIPE, "invalid seek") \ #define UV_ERRNO_GEN(val, name, s) UV_##name = val, diff --git a/deps/uv/src/unix/error.c b/deps/uv/src/unix/error.c index 9fbb312eef..b2add994a0 100644 --- a/deps/uv/src/unix/error.c +++ b/deps/uv/src/unix/error.c @@ -68,6 +68,7 @@ uv_err_code uv_translate_sys_error(int sys_errno) { case EAFNOSUPPORT: return UV_EAFNOSUPPORT; case EBADF: return UV_EBADF; case EPIPE: return UV_EPIPE; + case ESPIPE: return UV_ESPIPE; case EAGAIN: return UV_EAGAIN; #if EWOULDBLOCK != EAGAIN case EWOULDBLOCK: return UV_EAGAIN; diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 9f87060aee..634d4a0613 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -86,6 +86,10 @@ void uv__udp_finish_close(uv_udp_t* handle) { req = ngx_queue_data(q, uv_udp_send_t, queue); uv__req_unregister(handle->loop, req); + if (req->bufs != req->bufsml) + free(req->bufs); + req->bufs = NULL; + if (req->send_cb) { /* FIXME proper error code like UV_EABORTED */ uv__set_artificial_error(handle->loop, UV_EINTR); @@ -171,6 +175,7 @@ static void uv__udp_run_completed(uv_udp_t* handle) { if (req->bufs != req->bufsml) free(req->bufs); + req->bufs = NULL; if (req->send_cb == NULL) continue; diff --git a/deps/uv/src/win/core.c b/deps/uv/src/win/core.c index 7a35580382..79fb655c0f 100644 --- a/deps/uv/src/win/core.c +++ b/deps/uv/src/win/core.c @@ -70,6 +70,9 @@ static void uv_loop_init(uv_loop_t* loop) { uv_fatal_error(GetLastError(), "CreateIoCompletionPort"); } + /* To prevent uninitialized memory access, loop->time must be intialized */ + /* to zero before calling uv_update_time for the first time. */ + loop->time = 0; uv_update_time(loop); ngx_queue_init(&loop->handle_queue); diff --git a/deps/uv/src/win/tcp.c b/deps/uv/src/win/tcp.c index e13c0f3dfe..9ac01401e1 100644 --- a/deps/uv/src/win/tcp.c +++ b/deps/uv/src/win/tcp.c @@ -547,7 +547,7 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { if(!handle->accept_reqs) { handle->accept_reqs = (uv_tcp_accept_t*) - malloc(simultaneous_accepts * sizeof(uv_tcp_accept_t)); + malloc(uv_simultaneous_server_accepts * sizeof(uv_tcp_accept_t)); if (!handle->accept_reqs) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); } @@ -571,6 +571,18 @@ int uv_tcp_listen(uv_tcp_t* handle, int backlog, uv_connection_cb cb) { uv_tcp_queue_accept(handle, req); } + + /* Initialize other unused requests too, because uv_tcp_endgame */ + /* doesn't know how how many requests were intialized, so it will */ + /* try to clean up {uv_simultaneous_server_accepts} requests. */ + for (i = simultaneous_accepts; i < uv_simultaneous_server_accepts; i++) { + req = &handle->accept_reqs[i]; + uv_req_init(loop, (uv_req_t*) req); + req->type = UV_ACCEPT; + req->accept_socket = INVALID_SOCKET; + req->data = handle; + req->wait_handle = INVALID_HANDLE_VALUE; + } } return 0;