From cb76999bad6f20f3643fd6a052511fdca51f0efa Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 5 Jun 2012 17:04:52 +0200 Subject: [PATCH] deps: upgrade libuv to 06e0319 --- deps/uv/src/unix/ev/ev.c | 1 - deps/uv/src/unix/stream.c | 11 +++++++++-- deps/uv/src/unix/udp.c | 8 +++++++- deps/uv/src/win/tty.c | 2 +- deps/uv/test/runner.c | 1 + 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/deps/uv/src/unix/ev/ev.c b/deps/uv/src/unix/ev/ev.c index a432bfbf6b96fa..b6e190f75f6c74 100644 --- a/deps/uv/src/unix/ev/ev.c +++ b/deps/uv/src/unix/ev/ev.c @@ -2554,7 +2554,6 @@ void ev_unref (EV_P) { --activecnt; - if (activecnt < 0) abort(); } void diff --git a/deps/uv/src/unix/stream.c b/deps/uv/src/unix/stream.c index 6f0d1378f6cddc..bcfa1c939c34c2 100644 --- a/deps/uv/src/unix/stream.c +++ b/deps/uv/src/unix/stream.c @@ -523,12 +523,19 @@ static void uv__read(uv_stream_t* stream) { struct cmsghdr* cmsg; char cmsg_space[64]; struct ev_loop* ev = stream->loop->ev; + int count; + + /* Prevent loop starvation when the data comes in as fast as (or faster than) + * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. + */ + count = 32; /* XXX: Maybe instead of having UV_READING we just test if * tcp->read_cb is NULL or not? */ - while ((stream->read_cb || stream->read2_cb) && - stream->flags & UV_READING) { + while ((stream->read_cb || stream->read2_cb) + && (stream->flags & UV_READING) + && (count-- > 0)) { assert(stream->alloc_cb); buf = stream->alloc_cb((uv_handle_t*)stream, 64 * 1024); diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 349bfae3cd614b..7d58fd9fe7ab4d 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -208,12 +208,17 @@ static void uv__udp_recvmsg(uv_udp_t* handle) { ssize_t nread; uv_buf_t buf; int flags; + int count; assert(handle->recv_cb != NULL); assert(handle->alloc_cb != NULL); + /* Prevent loop starvation when the data comes in as fast as (or faster than) + * we can read it. XXX Need to rearm fd if we switch to edge-triggered I/O. + */ + count = 32; + do { - /* FIXME: hoist alloc_cb out the loop but for now follow uv__read() */ buf = handle->alloc_cb((uv_handle_t*)handle, 64 * 1024); assert(buf.len > 0); assert(buf.base != NULL); @@ -254,6 +259,7 @@ static void uv__udp_recvmsg(uv_udp_t* handle) { } /* recv_cb callback may decide to pause or close the handle */ while (nread != -1 + && count-- > 0 && handle->fd != -1 && handle->recv_cb != NULL); } diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index 601bf5ed169478..df7ae2898abec8 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -688,7 +688,7 @@ void uv_process_tty_read_line_req(uv_loop_t* loop, uv_tty_t* handle, if (!REQ_SUCCESS(req)) { /* Read was not successful */ if ((handle->flags & UV_HANDLE_READING) && - !(handle->flags & UV_HANDLE_TTY_RAW)) { + handle->read_line_handle != NULL) { /* Real error */ handle->flags &= ~UV_HANDLE_READING; uv__set_sys_error(loop, GET_REQ_ERROR(req)); diff --git a/deps/uv/test/runner.c b/deps/uv/test/runner.c index 73570fc332c94c..d4903379ffe20b 100644 --- a/deps/uv/test/runner.c +++ b/deps/uv/test/runner.c @@ -86,6 +86,7 @@ int run_test(const char* test, int timeout, int benchmark_output) { int i; status = 255; + main_proc = NULL; process_count = 0; /* If it's a helper the user asks for, start it directly. */