From 0e6e4abedcfe02ccf5da4c4257faa113170c20b4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 14 Jan 2012 01:21:25 +0100 Subject: [PATCH] unix: fix udp recv_start refcount Calling uv_udp_recv_start() should not bump the event loop's reference count. Fixes failing test udp_ref2. --- src/unix/udp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/unix/udp.c b/src/unix/udp.c index 223235dd..6760c310 100644 --- a/src/unix/udp.c +++ b/src/unix/udp.c @@ -42,6 +42,10 @@ static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[], static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) { int flags; + if (ev_is_active(w)) { + return; + } + assert(w == &handle->read_watcher || w == &handle->write_watcher); @@ -51,17 +55,23 @@ static void uv__udp_watcher_start(uv_udp_t* handle, ev_io* w) { ev_set_cb(w, uv__udp_io); ev_io_set(w, handle->fd, flags); ev_io_start(handle->loop->ev, w); + ev_unref(handle->loop->ev); } void uv__udp_watcher_stop(uv_udp_t* handle, ev_io* w) { int flags; + if (!ev_is_active(w)) { + return; + } + assert(w == &handle->read_watcher || w == &handle->write_watcher); flags = (w == &handle->read_watcher ? EV_READ : EV_WRITE); + ev_ref(handle->loop->ev); ev_io_stop(handle->loop->ev, w); ev_io_set(w, -1, flags); ev_set_cb(w, NULL);