Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
unix: fix udp recv_start refcount
Browse files Browse the repository at this point in the history
Calling uv_udp_recv_start() should not bump the event loop's reference count.

Fixes failing test udp_ref2.
  • Loading branch information
bnoordhuis committed Jan 14, 2012
1 parent 6d9c9a5 commit 0e6e4ab
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/unix/udp.c
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 0e6e4ab

Please sign in to comment.