Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Unix: refactor uv_poll refcount handling

  • Loading branch information
piscisaureus committed May 15, 2012
1 parent 97948e6 commit 14fd32be201b8af2d49e9e358a5d63d5456da1ce
Showing with 5 additions and 8 deletions.
  1. +5 −8 src/unix/poll.c
@@ -21,6 +21,7 @@

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

#include <unistd.h>
#include <assert.h>
@@ -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;
@@ -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);
}


@@ -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;
}

0 comments on commit 14fd32b

Please sign in to comment.
You can’t perform that action at this time.