summaryrefslogtreecommitdiff
path: root/deps/uv/src/unix/pipe.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2012-11-16 17:57:15 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2012-11-16 17:58:42 +0100
commitb6a3b0a6297ee205aa34d357edd55b79f91cdf09 (patch)
treef962b088681f43d7a17615cad54fedbf938b00f8 /deps/uv/src/unix/pipe.c
parente2bcff9aa75e51b9ba071330fe712180abed03e0 (diff)
downloadandroid-node-v8-b6a3b0a6297ee205aa34d357edd55b79f91cdf09.tar.gz
android-node-v8-b6a3b0a6297ee205aa34d357edd55b79f91cdf09.tar.bz2
android-node-v8-b6a3b0a6297ee205aa34d357edd55b79f91cdf09.zip
deps: upgrade libuv to 665a316
Diffstat (limited to 'deps/uv/src/unix/pipe.c')
-rw-r--r--deps/uv/src/unix/pipe.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/deps/uv/src/unix/pipe.c b/deps/uv/src/unix/pipe.c
index 860f7d2d53..f432f4539a 100644
--- a/deps/uv/src/unix/pipe.c
+++ b/deps/uv/src/unix/pipe.c
@@ -29,7 +29,7 @@
#include <unistd.h>
#include <stdlib.h>
-static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events);
+static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned int events);
int uv_pipe_init(uv_loop_t* loop, uv_pipe_t* handle, int ipc) {
@@ -57,7 +57,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
bound = 0;
/* Already bound? */
- if (handle->fd >= 0) {
+ if (handle->io_watcher.fd >= 0) {
uv__set_artificial_error(handle->loop, UV_EINVAL);
goto out;
}
@@ -89,7 +89,7 @@ int uv_pipe_bind(uv_pipe_t* handle, const char* name) {
/* Success. */
handle->pipe_fname = pipe_fname; /* Is a strdup'ed copy. */
- handle->fd = sockfd;
+ handle->io_watcher.fd = sockfd;
status = 0;
out:
@@ -117,21 +117,18 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
saved_errno = errno;
status = -1;
- if (handle->fd == -1) {
+ if (handle->io_watcher.fd == -1) {
uv__set_artificial_error(handle->loop, UV_EINVAL);
goto out;
}
- assert(handle->fd >= 0);
+ assert(handle->io_watcher.fd >= 0);
- if ((status = listen(handle->fd, backlog)) == -1) {
+ if ((status = listen(handle->io_watcher.fd, backlog)) == -1) {
uv__set_sys_error(handle->loop, errno);
} else {
handle->connection_cb = cb;
- uv__io_init(&handle->read_watcher,
- uv__pipe_accept,
- handle->fd,
- UV__IO_READ);
- uv__io_start(handle->loop, &handle->read_watcher);
+ handle->io_watcher.cb = uv__pipe_accept;
+ uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN);
}
out:
@@ -175,11 +172,11 @@ void uv_pipe_connect(uv_connect_t* req,
int r;
saved_errno = errno;
- new_sock = (handle->fd == -1);
+ new_sock = (handle->io_watcher.fd == -1);
err = -1;
if (new_sock)
- if ((handle->fd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+ if ((handle->io_watcher.fd = uv__socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
goto out;
memset(&saddr, 0, sizeof saddr);
@@ -190,7 +187,7 @@ void uv_pipe_connect(uv_connect_t* req,
* is either there or not.
*/
do {
- r = connect(handle->fd, (struct sockaddr*)&saddr, sizeof saddr);
+ r = connect(handle->io_watcher.fd, (struct sockaddr*)&saddr, sizeof saddr);
}
while (r == -1 && errno == EINTR);
@@ -199,12 +196,11 @@ void uv_pipe_connect(uv_connect_t* req,
if (new_sock)
if (uv__stream_open((uv_stream_t*)handle,
- handle->fd,
+ handle->io_watcher.fd,
UV_STREAM_READABLE | UV_STREAM_WRITABLE))
goto out;
- uv__io_start(handle->loop, &handle->read_watcher);
- uv__io_start(handle->loop, &handle->write_watcher);
+ uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
err = 0;
out:
@@ -217,7 +213,7 @@ out:
ngx_queue_init(&req->queue);
/* Run callback on next tick. */
- uv__io_feed(handle->loop, &handle->write_watcher, UV__IO_WRITE);
+ uv__io_feed(handle->loop, &handle->io_watcher);
/* Mimic the Windows pipe implementation, always
* return 0 and let the callback handle errors.
@@ -227,17 +223,17 @@ out:
/* TODO merge with uv__server_io()? */
-static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {
+static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
uv_pipe_t* pipe;
int saved_errno;
int sockfd;
saved_errno = errno;
- pipe = container_of(w, uv_pipe_t, read_watcher);
+ pipe = container_of(w, uv_pipe_t, io_watcher);
assert(pipe->type == UV_NAMED_PIPE);
- sockfd = uv__accept(pipe->fd);
+ sockfd = uv__accept(pipe->io_watcher.fd);
if (sockfd == -1) {
if (errno != EAGAIN && errno != EWOULDBLOCK) {
uv__set_sys_error(pipe->loop, errno);
@@ -248,7 +244,7 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, int events) {
pipe->connection_cb((uv_stream_t*)pipe, 0);
if (pipe->accepted_fd == sockfd) {
/* The user hasn't called uv_accept() yet */
- uv__io_stop(pipe->loop, &pipe->read_watcher);
+ uv__io_stop(pipe->loop, &pipe->io_watcher, UV__POLLIN);
}
}