unix: rename UV__IO_* constants

This commit is contained in:
Ben Noordhuis 2012-11-15 23:53:18 +01:00
parent 1282d64868
commit 65bb6f068e
13 changed files with 81 additions and 81 deletions

View File

@ -105,7 +105,7 @@ static int uv__async_init(uv_loop_t* loop) {
return -1;
uv__io_init(&loop->async_watcher, uv__async_io, loop->async_pipefd[0]);
uv__io_start(loop, &loop->async_watcher, UV__IO_READ);
uv__io_start(loop, &loop->async_watcher, UV__POLLIN);
return 0;
}

View File

@ -536,7 +536,7 @@ static void uv__run_pending(uv_loop_t* loop) {
ngx_queue_init(q);
w = ngx_queue_data(q, uv__io_t, pending_queue);
w->cb(loop, w, UV__IO_WRITE);
w->cb(loop, w, UV__POLLOUT);
}
}
@ -595,7 +595,7 @@ void uv__io_init(uv__io_t* w, uv__io_cb cb, int fd) {
void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);
assert(w->fd >= 0);
assert(w->fd < INT_MAX);
@ -614,7 +614,7 @@ void uv__io_start(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
void uv__io_stop(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);
if (w->fd == -1)
@ -655,7 +655,7 @@ void uv__io_feed(uv_loop_t* loop, uv__io_t* w) {
int uv__io_active(const uv__io_t* w, unsigned int events) {
assert(0 == (events & ~(UV__IO_READ | UV__IO_WRITE)));
assert(0 == (events & ~(UV__POLLIN | UV__POLLOUT)));
assert(0 != events);
return 0 != (w->pevents & events);
}

View File

@ -83,33 +83,33 @@
while (0)
#if defined(__linux__)
# define UV__IO_READ UV__EPOLLIN
# define UV__IO_WRITE UV__EPOLLOUT
# define UV__IO_ERROR UV__EPOLLERR
# define UV__IO_HUP UV__EPOLLHUP
# define UV__POLLIN UV__EPOLLIN
# define UV__POLLOUT UV__EPOLLOUT
# define UV__POLLERR UV__EPOLLERR
# define UV__POLLHUP UV__EPOLLHUP
#endif
#if defined(__sun)
# define UV__IO_READ POLLIN
# define UV__IO_WRITE POLLOUT
# define UV__IO_ERROR POLLERR
# define UV__IO_HUP POLLHUP
# define UV__POLLIN POLLIN
# define UV__POLLOUT POLLOUT
# define UV__POLLERR POLLERR
# define UV__POLLHUP POLLHUP
#endif
#ifndef UV__IO_READ
# define UV__IO_READ 1
#ifndef UV__POLLIN
# define UV__POLLIN 1
#endif
#ifndef UV__IO_WRITE
# define UV__IO_WRITE 2
#ifndef UV__POLLOUT
# define UV__POLLOUT 2
#endif
#ifndef UV__IO_ERROR
# define UV__IO_ERROR 4
#ifndef UV__POLLERR
# define UV__POLLERR 4
#endif
#ifndef UV__IO_HUP
# define UV__IO_HUP 8
#ifndef UV__POLLHUP
# define UV__POLLHUP 8
#endif
/* handle flags */

View File

@ -90,7 +90,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
if (w->events == w->pevents)
continue;
if ((w->events & UV__IO_READ) == 0 && (w->pevents & UV__IO_READ) != 0) {
if ((w->events & UV__POLLIN) == 0 && (w->pevents & UV__POLLIN) != 0) {
filter = EVFILT_READ;
fflags = 0;
op = EV_ADD;
@ -111,7 +111,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
}
if ((w->events & UV__IO_WRITE) == 0 && (w->pevents & UV__IO_WRITE) != 0) {
if ((w->events & UV__POLLOUT) == 0 && (w->pevents & UV__POLLOUT) != 0) {
EV_SET(events + nevents, w->fd, EVFILT_WRITE, EV_ADD, 0, 0, 0);
if (++nevents == ARRAY_SIZE(events)) {
@ -181,8 +181,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
if (ev->filter == EVFILT_VNODE) {
assert(w->events == UV__IO_READ);
assert(w->pevents == UV__IO_READ);
assert(w->events == UV__POLLIN);
assert(w->pevents == UV__POLLIN);
w->cb(loop, w, ev->fflags); /* XXX always uv__fs_event() */
nevents++;
continue;
@ -191,8 +191,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
revents = 0;
if (ev->filter == EVFILT_READ) {
if (w->events & UV__IO_READ)
revents |= UV__IO_READ;
if (w->events & UV__POLLIN)
revents |= UV__POLLIN;
else {
/* TODO batch up */
struct kevent events[1];
@ -202,8 +202,8 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
if (ev->filter == EVFILT_WRITE) {
if (w->events & UV__IO_WRITE)
revents |= UV__IO_WRITE;
if (w->events & UV__POLLOUT)
revents |= UV__POLLOUT;
else {
/* TODO batch up */
struct kevent events[1];
@ -213,7 +213,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
}
if (ev->flags & EV_ERROR)
revents |= UV__IO_ERROR;
revents |= UV__POLLERR;
if (revents == 0)
continue;
@ -320,7 +320,7 @@ int uv_fs_event_init(uv_loop_t* loop,
fallback:
#endif /* defined(__APPLE__) */
uv__io_start(loop, &handle->event_watcher, UV__IO_READ);
uv__io_start(loop, &handle->event_watcher, UV__POLLIN);
return 0;
}
@ -329,9 +329,9 @@ fallback:
void uv__fs_event_close(uv_fs_event_t* handle) {
#if defined(__APPLE__)
if (uv__fsevents_close(handle))
uv__io_stop(handle->loop, &handle->event_watcher, UV__IO_READ);
uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN);
#else
uv__io_stop(handle->loop, &handle->event_watcher, UV__IO_READ);
uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN);
#endif /* defined(__APPLE__) */
uv__handle_stop(handle);

View File

@ -101,7 +101,7 @@ static int init_inotify(uv_loop_t* loop) {
}
uv__io_init(&loop->inotify_read_watcher, uv__inotify_read, loop->inotify_fd);
uv__io_start(loop, &loop->inotify_read_watcher, UV__IO_READ);
uv__io_start(loop, &loop->inotify_read_watcher, UV__POLLIN);
return 0;
}

View File

@ -105,7 +105,7 @@ int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
void uv__platform_loop_delete(uv_loop_t* loop) {
if (loop->inotify_fd == -1) return;
uv__io_stop(loop, &loop->inotify_read_watcher, UV__IO_READ);
uv__io_stop(loop, &loop->inotify_read_watcher, UV__POLLIN);
close(loop->inotify_fd);
loop->inotify_fd = -1;
}

View File

@ -128,7 +128,7 @@ int uv_pipe_listen(uv_pipe_t* handle, int backlog, uv_connection_cb cb) {
} else {
handle->connection_cb = cb;
handle->io_watcher.cb = uv__pipe_accept;
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_READ);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN);
}
out:
@ -200,7 +200,7 @@ void uv_pipe_connect(uv_connect_t* req,
UV_STREAM_READABLE | UV_STREAM_WRITABLE))
goto out;
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_READ|UV__IO_WRITE);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
err = 0;
out:
@ -244,7 +244,7 @@ static void uv__pipe_accept(uv_loop_t* loop, uv__io_t* w, unsigned 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->io_watcher, UV__IO_READ);
uv__io_stop(pipe->loop, &pipe->io_watcher, UV__POLLIN);
}
}

View File

@ -33,8 +33,8 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
handle = container_of(w, uv_poll_t, io_watcher);
if (events & UV__IO_ERROR) {
uv__io_stop(loop, w, UV__IO_READ | UV__IO_WRITE);
if (events & UV__POLLERR) {
uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT);
uv__handle_stop(handle);
uv__set_sys_error(handle->loop, EBADF);
handle->poll_cb(handle, -1, 0);
@ -42,9 +42,9 @@ static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
}
pevents = 0;
if (events & UV__IO_READ)
if (events & UV__POLLIN)
pevents |= UV_READABLE;
if (events & UV__IO_WRITE)
if (events & UV__POLLOUT)
pevents |= UV_WRITABLE;
handle->poll_cb(handle, 0, pevents);
@ -66,7 +66,7 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
static void uv__poll_stop(uv_poll_t* handle) {
uv__io_stop(handle->loop, &handle->io_watcher, UV__IO_READ | UV__IO_WRITE);
uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
uv__handle_stop(handle);
}
@ -91,9 +91,9 @@ int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) {
events = 0;
if (pevents & UV_READABLE)
events |= UV__IO_READ;
events |= UV__POLLIN;
if (pevents & UV_WRITABLE)
events |= UV__IO_WRITE;
events |= UV__POLLOUT;
uv__io_start(handle->loop, &handle->io_watcher, events);
uv__handle_start(handle);

View File

@ -213,7 +213,7 @@ static int uv__signal_loop_once_init(uv_loop_t* loop) {
uv__io_init(&loop->signal_io_watcher,
uv__signal_event,
loop->signal_pipefd[0]);
uv__io_start(loop, &loop->signal_io_watcher, UV__IO_READ);
uv__io_start(loop, &loop->signal_io_watcher, UV__POLLIN);
return 0;
}

View File

@ -131,7 +131,7 @@ void uv__stream_destroy(uv_stream_t* stream) {
uv_write_t* req;
ngx_queue_t* q;
assert(!uv__io_active(&stream->io_watcher, UV__IO_READ | UV__IO_WRITE));
assert(!uv__io_active(&stream->io_watcher, UV__POLLIN | UV__POLLOUT));
assert(stream->flags & UV_CLOSED);
if (stream->connect_req) {
@ -229,12 +229,12 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
int r;
stream = container_of(w, uv_stream_t, io_watcher);
assert(events == UV__IO_READ);
assert(events == UV__POLLIN);
assert(stream->accepted_fd == -1);
assert(!(stream->flags & UV_CLOSING));
if (stream->accepted_fd == -1)
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_READ);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN);
/* connection_cb can close the server socket while we're
* in the loop so check it on each iteration.
@ -281,7 +281,7 @@ void uv__server_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
if (stream->accepted_fd != -1) {
/* The user hasn't yet accepted called uv_accept() */
uv__io_stop(loop, &stream->io_watcher, UV__IO_READ);
uv__io_stop(loop, &stream->io_watcher, UV__POLLIN);
return;
}
@ -322,7 +322,7 @@ int uv_accept(uv_stream_t* server, uv_stream_t* client) {
goto out;
}
uv__io_start(streamServer->loop, &streamServer->io_watcher, UV__IO_READ);
uv__io_start(streamServer->loop, &streamServer->io_watcher, UV__POLLIN);
streamServer->accepted_fd = -1;
status = 0;
@ -382,7 +382,7 @@ static void uv__drain(uv_stream_t* stream) {
assert(!uv_write_queue_head(stream));
assert(stream->write_queue_size == 0);
uv__io_stop(stream->loop, &stream->io_watcher, UV__IO_WRITE);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLOUT);
/* Shutdown? */
if ((stream->flags & UV_STREAM_SHUTTING) &&
@ -592,7 +592,7 @@ start:
assert(!(stream->flags & UV_STREAM_BLOCKING));
/* We're not done. */
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_WRITE);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT);
}
@ -700,7 +700,7 @@ static void uv__read(uv_stream_t* stream) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* Wait for the next one. */
if (stream->flags & UV_STREAM_READING) {
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_READ);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN);
}
uv__set_sys_error(stream->loop, EAGAIN);
@ -721,16 +721,16 @@ static void uv__read(uv_stream_t* stream) {
stream->read2_cb((uv_pipe_t*)stream, -1, buf, UV_UNKNOWN_HANDLE);
}
assert(!uv__io_active(&stream->io_watcher, UV__IO_READ));
assert(!uv__io_active(&stream->io_watcher, UV__POLLIN));
return;
}
} else if (nread == 0) {
/* EOF */
uv__set_artificial_error(stream->loop, UV_EOF);
uv__io_stop(stream->loop, &stream->io_watcher, UV__IO_READ);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
if (!uv__io_active(&stream->io_watcher, UV__IO_WRITE))
if (!uv__io_active(&stream->io_watcher, UV__POLLOUT))
uv__handle_stop(stream);
if (stream->read_cb) {
@ -815,7 +815,7 @@ int uv_shutdown(uv_shutdown_t* req, uv_stream_t* stream, uv_shutdown_cb cb) {
stream->shutdown_req = req;
stream->flags |= UV_STREAM_SHUTTING;
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_WRITE);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT);
return 0;
}
@ -836,7 +836,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return;
}
if (events & UV__IO_READ) {
if (events & UV__POLLIN) {
assert(stream->io_watcher.fd >= 0);
uv__read(stream);
@ -845,7 +845,7 @@ static void uv__stream_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) {
return; /* read_cb closed stream. */
}
if (events & UV__IO_WRITE) {
if (events & UV__POLLOUT) {
assert(stream->io_watcher.fd >= 0);
uv__write(stream);
uv__write_callbacks(stream);
@ -958,7 +958,7 @@ int uv_write2(uv_write_t* req,
* sufficiently flushed in uv__write.
*/
assert(!(stream->flags & UV_STREAM_BLOCKING));
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_WRITE);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLOUT);
}
return 0;
@ -1000,7 +1000,7 @@ int uv__read_start_common(uv_stream_t* stream, uv_alloc_cb alloc_cb,
stream->read2_cb = read2_cb;
stream->alloc_cb = alloc_cb;
uv__io_start(stream->loop, &stream->io_watcher, UV__IO_READ);
uv__io_start(stream->loop, &stream->io_watcher, UV__POLLIN);
uv__handle_start(stream);
return 0;
@ -1020,7 +1020,7 @@ int uv_read2_start(uv_stream_t* stream, uv_alloc_cb alloc_cb,
int uv_read_stop(uv_stream_t* stream) {
uv__io_stop(stream->loop, &stream->io_watcher, UV__IO_READ);
uv__io_stop(stream->loop, &stream->io_watcher, UV__POLLIN);
uv__handle_stop(stream);
stream->flags &= ~UV_STREAM_READING;
stream->read_cb = NULL;
@ -1042,7 +1042,7 @@ int uv_is_writable(const uv_stream_t* stream) {
void uv__stream_close(uv_stream_t* handle) {
uv_read_stop(handle);
uv__io_stop(handle->loop, &handle->io_watcher, UV__IO_WRITE);
uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLOUT);
close(handle->io_watcher.fd);
handle->io_watcher.fd = -1;
@ -1052,5 +1052,5 @@ void uv__stream_close(uv_stream_t* handle) {
handle->accepted_fd = -1;
}
assert(!uv__io_active(&handle->io_watcher, UV__IO_READ|UV__IO_WRITE));
assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT));
}

View File

@ -368,7 +368,7 @@ int uv_fs_event_init(uv_loop_t* loop,
if (first_run) {
uv__io_init(&loop->fs_event_watcher, uv__fs_event_read, portfd);
uv__io_start(loop, &loop->fs_event_watcher, UV__IO_READ);
uv__io_start(loop, &loop->fs_event_watcher, UV__POLLIN);
}
return 0;

View File

@ -127,7 +127,7 @@ static int uv__connect(uv_connect_t* req,
ngx_queue_init(&req->queue);
handle->connect_req = req;
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_WRITE);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT);
if (handle->delayed_error)
uv__io_feed(handle->loop, &handle->io_watcher);
@ -257,7 +257,7 @@ int uv_tcp_listen(uv_tcp_t* tcp, int backlog, uv_connection_cb cb) {
/* Start listening for connections. */
tcp->io_watcher.cb = uv__server_io;
uv__io_start(tcp->loop, &tcp->io_watcher, UV__IO_READ);
uv__io_start(tcp->loop, &tcp->io_watcher, UV__POLLIN);
return 0;
}

View File

@ -40,7 +40,7 @@ static int uv__udp_send(uv_udp_send_t* req, uv_udp_t* handle, uv_buf_t bufs[],
void uv__udp_close(uv_udp_t* handle) {
uv__io_stop(handle->loop, &handle->io_watcher, UV__IO_READ|UV__IO_WRITE);
uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT);
uv__handle_stop(handle);
close(handle->io_watcher.fd);
handle->io_watcher.fd = -1;
@ -51,7 +51,7 @@ void uv__udp_finish_close(uv_udp_t* handle) {
uv_udp_send_t* req;
ngx_queue_t* q;
assert(!uv__io_active(&handle->io_watcher, UV__IO_READ|UV__IO_WRITE));
assert(!uv__io_active(&handle->io_watcher, UV__POLLIN | UV__POLLOUT));
assert(handle->io_watcher.fd == -1);
uv__udp_run_completed(handle);
@ -172,10 +172,10 @@ static void uv__udp_run_completed(uv_udp_t* handle) {
static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) {
if (revents & UV__IO_READ)
if (revents & UV__POLLIN)
uv__udp_recvmsg(loop, w, revents);
if (revents & UV__IO_WRITE)
if (revents & UV__POLLOUT)
uv__udp_sendmsg(loop, w, revents);
}
@ -193,7 +193,7 @@ static void uv__udp_recvmsg(uv_loop_t* loop,
handle = container_of(w, uv_udp_t, io_watcher);
assert(handle->type == UV_UDP);
assert(revents & UV__IO_READ);
assert(revents & UV__POLLIN);
assert(handle->recv_cb != NULL);
assert(handle->alloc_cb != NULL);
@ -258,7 +258,7 @@ static void uv__udp_sendmsg(uv_loop_t* loop,
handle = container_of(w, uv_udp_t, io_watcher);
assert(handle->type == UV_UDP);
assert(revents & UV__IO_WRITE);
assert(revents & UV__POLLOUT);
assert(!ngx_queue_empty(&handle->write_queue)
|| !ngx_queue_empty(&handle->write_completed_queue));
@ -275,9 +275,9 @@ static void uv__udp_sendmsg(uv_loop_t* loop,
}
else if (ngx_queue_empty(&handle->write_queue)) {
/* Pending queue and completion queue empty, stop watcher. */
uv__io_stop(loop, &handle->io_watcher, UV__IO_WRITE);
uv__io_stop(loop, &handle->io_watcher, UV__POLLOUT);
if (!uv__io_active(&handle->io_watcher, UV__IO_READ))
if (!uv__io_active(&handle->io_watcher, UV__POLLIN))
uv__handle_stop(handle);
}
}
@ -439,7 +439,7 @@ static int uv__udp_send(uv_udp_send_t* req,
memcpy(req->bufs, bufs, bufcnt * sizeof(bufs[0]));
ngx_queue_insert_tail(&handle->write_queue, &req->queue);
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_WRITE);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLOUT);
uv__handle_start(handle);
return 0;
@ -674,7 +674,7 @@ int uv_udp_recv_start(uv_udp_t* handle,
return -1;
}
if (uv__io_active(&handle->io_watcher, UV__IO_READ)) {
if (uv__io_active(&handle->io_watcher, UV__POLLIN)) {
uv__set_artificial_error(handle->loop, UV_EALREADY);
return -1;
}
@ -685,7 +685,7 @@ int uv_udp_recv_start(uv_udp_t* handle,
handle->alloc_cb = alloc_cb;
handle->recv_cb = recv_cb;
uv__io_start(handle->loop, &handle->io_watcher, UV__IO_READ);
uv__io_start(handle->loop, &handle->io_watcher, UV__POLLIN);
uv__handle_start(handle);
return 0;
@ -693,9 +693,9 @@ int uv_udp_recv_start(uv_udp_t* handle,
int uv_udp_recv_stop(uv_udp_t* handle) {
uv__io_stop(handle->loop, &handle->io_watcher, UV__IO_READ);
uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN);
if (!uv__io_active(&handle->io_watcher, UV__IO_WRITE))
if (!uv__io_active(&handle->io_watcher, UV__POLLOUT))
uv__handle_stop(handle);
handle->alloc_cb = NULL;