diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-11-08 22:40:36 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-11-08 22:40:36 +0000 |
commit | dd36982ad51632bc47ce7b73cad0696e85d593c3 (patch) | |
tree | edb86b1ff2689f20522150f2e1fbeb0600f7a58c /buffer-poll.c | |
parent | 5ce49941fb8ab4ce65df4ef872028ab89fd855ae (diff) | |
download | rtmux-dd36982ad51632bc47ce7b73cad0696e85d593c3.tar.gz rtmux-dd36982ad51632bc47ce7b73cad0696e85d593c3.tar.bz2 rtmux-dd36982ad51632bc47ce7b73cad0696e85d593c3.zip |
Sync OpenBSD patchset 491:
Initial changes to move tmux to libevent.
This moves the client-side loops are pretty much fully over to event-based only
(tmux.c and client.c) but server-side (server.c and friends) treats libevent as
a sort of clever poll, waking up after every event to run various things.
Moving the server stuff over to bufferevents and timers and so on will come
later.
Diffstat (limited to 'buffer-poll.c')
-rw-r--r-- | buffer-poll.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/buffer-poll.c b/buffer-poll.c index 63b45f47..20ce7b78 100644 --- a/buffer-poll.c +++ b/buffer-poll.c @@ -1,4 +1,4 @@ -/* $Id: buffer-poll.c,v 1.18 2009-10-23 17:49:47 tcunha Exp $ */ +/* $Id: buffer-poll.c,v 1.19 2009-11-08 22:40:36 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <errno.h> +#include <event.h> #include <unistd.h> #include "tmux.h" @@ -29,9 +30,7 @@ buffer_poll(int fd, int events, struct buffer *in, struct buffer *out) { ssize_t n; - if (events & (POLLERR|POLLNVAL)) - return (-1); - if (in != NULL && events & POLLIN) { + if (in != NULL && events & EV_READ) { buffer_ensure(in, BUFSIZ); n = read(fd, BUFFER_IN(in), BUFFER_FREE(in)); if (n == 0) @@ -41,9 +40,8 @@ buffer_poll(int fd, int events, struct buffer *in, struct buffer *out) return (-1); } else buffer_add(in, n); - } else if (events & POLLHUP) - return (-1); - if (out != NULL && BUFFER_USED(out) > 0 && events & POLLOUT) { + } + if (out != NULL && BUFFER_USED(out) > 0 && events & EV_WRITE) { n = write(fd, BUFFER_OUT(out), BUFFER_USED(out)); if (n == -1) { if (errno != EINTR && errno != EAGAIN) |