diff options
author | 2009-11-04 20:50:11 +0000 | |
---|---|---|
committer | 2009-11-04 20:50:11 +0000 | |
commit | 7724d0b04b4f2528a8d67e663d05e77e3237c298 (patch) | |
tree | 23ea2510233e47e6520df4c70b323a2ae9c187d4 /usr.bin/tmux/buffer-poll.c | |
parent | Unused (but assigned to) variable, found by lint. (diff) | |
download | wireguard-openbsd-7724d0b04b4f2528a8d67e663d05e77e3237c298.tar.xz wireguard-openbsd-7724d0b04b4f2528a8d67e663d05e77e3237c298.zip |
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 'usr.bin/tmux/buffer-poll.c')
-rw-r--r-- | usr.bin/tmux/buffer-poll.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.bin/tmux/buffer-poll.c b/usr.bin/tmux/buffer-poll.c index 6cdfc402efc..f88c418aca0 100644 --- a/usr.bin/tmux/buffer-poll.c +++ b/usr.bin/tmux/buffer-poll.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer-poll.c,v 1.4 2009/10/22 19:41:51 nicm Exp $ */ +/* $OpenBSD: buffer-poll.c,v 1.5 2009/11/04 20:50:11 nicm 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) |