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

Commit

Permalink
sunos: handle rearm errors
Browse files Browse the repository at this point in the history
fix #1078
  • Loading branch information
indutny committed Feb 18, 2014
1 parent 4f913b6 commit 703a9e6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/unix/sunos.c
Expand Up @@ -303,18 +303,20 @@ void uv_loadavg(double avg[3]) {

#if defined(PORT_SOURCE_FILE)

static void uv__fs_event_rearm(uv_fs_event_t *handle) {
static int uv__fs_event_rearm(uv_fs_event_t* handle) {
if (handle->fd == -1)
return;
return 0;

if (port_associate(handle->loop->fs_fd,
PORT_SOURCE_FILE,
(uintptr_t) &handle->fo,
FILE_ATTRIB | FILE_MODIFIED,
handle) == -1) {
uv__set_sys_error(handle->loop, errno);
return -1;
}
handle->fd = PORT_LOADED;
return 0;
}


Expand Down Expand Up @@ -361,11 +363,12 @@ static void uv__fs_event_read(uv_loop_t* loop,
assert(events != 0);
handle->fd = PORT_FIRED;
handle->cb(handle, NULL, events, 0);

if (handle->fd != PORT_DELETED)
if (uv__fs_event_rearm(handle) != 0)
handle->cb(handle, NULL, 0, -1);
}
while (handle->fd != PORT_DELETED);

if (handle != NULL && handle->fd != PORT_DELETED)
uv__fs_event_rearm(handle);
}


Expand All @@ -387,14 +390,16 @@ int uv_fs_event_init(uv_loop_t* loop,
}

uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
uv__handle_start(handle); /* FIXME shouldn't start automatically */
handle->filename = strdup(filename);
handle->fd = PORT_UNUSED;
handle->cb = cb;

memset(&handle->fo, 0, sizeof handle->fo);
handle->fo.fo_name = handle->filename;
uv__fs_event_rearm(handle);
if (uv__fs_event_rearm(handle) != 0)
return -1;

uv__handle_start(handle); /* FIXME shouldn't start automatically */

if (first_run) {
uv__io_init(&loop->fs_event_watcher, uv__fs_event_read, portfd);
Expand Down

0 comments on commit 703a9e6

Please sign in to comment.