diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-06-05 15:45:46 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-06-05 16:48:17 +0200 |
commit | 0a2076b26ac0dee453d664e0d0d6a0cc934bd579 (patch) | |
tree | 3b47e7a48d5ab6e9994835be430a0d333218228e /deps/uv/src/unix/udp.c | |
parent | 27061cc9f45afbc4ddc1efa8bed1ea22df7cb0f4 (diff) | |
download | android-node-v8-0a2076b26ac0dee453d664e0d0d6a0cc934bd579.tar.gz android-node-v8-0a2076b26ac0dee453d664e0d0d6a0cc934bd579.tar.bz2 android-node-v8-0a2076b26ac0dee453d664e0d0d6a0cc934bd579.zip |
deps: upgrade libuv to c8c9fe1
Diffstat (limited to 'deps/uv/src/unix/udp.c')
-rw-r--r-- | deps/uv/src/unix/udp.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 523d2823d2..9f87060aee 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -196,6 +196,7 @@ static void uv__udp_recvmsg(uv_loop_t* loop, uv__io_t* w, int revents) { ssize_t nread; uv_buf_t buf; int flags; + int count; handle = container_of(w, uv_udp_t, read_watcher); assert(handle->type == UV_UDP); @@ -204,15 +205,20 @@ static void uv__udp_recvmsg(uv_loop_t* loop, uv__io_t* w, int revents) { 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; + + memset(&h, 0, sizeof(h)); + h.msg_name = &peer; + 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); - memset(&h, 0, sizeof h); - h.msg_name = &peer; - h.msg_namelen = sizeof peer; + h.msg_namelen = sizeof(peer); h.msg_iov = (struct iovec*)&buf; h.msg_iovlen = 1; @@ -246,6 +252,7 @@ static void uv__udp_recvmsg(uv_loop_t* loop, uv__io_t* w, int revents) { } /* recv_cb callback may decide to pause or close the handle */ while (nread != -1 + && count-- > 0 && handle->fd != -1 && handle->recv_cb != NULL); } |