|
|
@ -268,7 +268,7 @@ static void uv__stream_osx_cb_close(uv_handle_t* async) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int uv__stream_try_select(uv_stream_t* stream, int fd) { |
|
|
|
int uv__stream_try_select(uv_stream_t* stream, int* fd) { |
|
|
|
/*
|
|
|
|
* kqueue doesn't work with some files from /dev mount on osx. |
|
|
|
* select(2) in separate thread for those fds |
|
|
@ -288,7 +288,7 @@ static int uv__stream_try_select(uv_stream_t* stream, int fd) { |
|
|
|
return uv__set_sys_error(stream->loop, errno); |
|
|
|
} |
|
|
|
|
|
|
|
EV_SET(&filter[0], fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); |
|
|
|
EV_SET(&filter[0], *fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); |
|
|
|
|
|
|
|
/* Use small timeout, because we only want to capture EINVALs */ |
|
|
|
timeout.tv_sec = 0; |
|
|
@ -308,7 +308,7 @@ static int uv__stream_try_select(uv_stream_t* stream, int fd) { |
|
|
|
if (s == NULL) |
|
|
|
return uv__set_artificial_error(stream->loop, UV_ENOMEM); |
|
|
|
|
|
|
|
s->fd = fd; |
|
|
|
s->fd = *fd; |
|
|
|
|
|
|
|
if (uv_async_init(stream->loop, &s->async, uv__stream_osx_select_cb)) { |
|
|
|
SAVE_ERRNO(free(s)); |
|
|
@ -336,6 +336,7 @@ static int uv__stream_try_select(uv_stream_t* stream, int fd) { |
|
|
|
|
|
|
|
s->stream = stream; |
|
|
|
stream->select = s; |
|
|
|
*fd = s->fake_fd; |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
@ -368,21 +369,6 @@ int uv__stream_open(uv_stream_t* stream, int fd, int flags) { |
|
|
|
return uv__set_sys_error(stream->loop, errno); |
|
|
|
} |
|
|
|
|
|
|
|
#if defined(__APPLE__) |
|
|
|
{ |
|
|
|
uv__stream_select_t* s; |
|
|
|
int r; |
|
|
|
|
|
|
|
r = uv__stream_try_select(stream, fd); |
|
|
|
if (r == -1) |
|
|
|
return r; |
|
|
|
|
|
|
|
s = stream->select; |
|
|
|
if (s != NULL) |
|
|
|
fd = s->fake_fd; |
|
|
|
} |
|
|
|
#endif /* defined(__APPLE__) */ |
|
|
|
|
|
|
|
stream->io_watcher.fd = fd; |
|
|
|
|
|
|
|
return 0; |
|
|
|