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

Commit

Permalink
Unix: refactor uv_poll refcount handling
Browse files Browse the repository at this point in the history
  • Loading branch information
piscisaureus committed May 15, 2012
1 parent 97948e6 commit 14fd32b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/unix/poll.c
Expand Up @@ -21,6 +21,7 @@

#include "uv.h"
#include "internal.h"
#include "../uv-common.h"

#include <unistd.h>
#include <assert.h>
Expand All @@ -34,7 +35,7 @@ static void uv__poll_io(EV_P_ ev_io* watcher, int ev_events) {
if (ev_events & EV_ERROR) {
/* An error happened. Libev has implicitly stopped the watcher, but we */
/* need to fix the refcount. */
uv_ref(handle->loop);
uv__handle_stop(handle);
uv__set_sys_error(handle->loop, EBADF);
handle->poll_cb(handle, -1, 0);
return;
Expand Down Expand Up @@ -74,10 +75,8 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,


static void uv__poll_stop(uv_poll_t* handle) {
if (ev_is_active(&handle->io_watcher)) {
ev_io_stop(handle->loop->ev, &handle->io_watcher);
uv_ref(handle->loop);
}
ev_io_stop(handle->loop->ev, &handle->io_watcher);
uv__handle_stop(handle);
}


Expand Down Expand Up @@ -111,10 +110,8 @@ int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb poll_cb) {
ev_io_set(&handle->io_watcher, handle->fd, ev_events);
ev_io_start(handle->loop->ev, &handle->io_watcher);

if (!was_active)
uv_unref(handle->loop);

handle->poll_cb = poll_cb;
uv__handle_start(handle);

return 0;
}
Expand Down

0 comments on commit 14fd32b

Please sign in to comment.