diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 20:50:12 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 20:50:12 +0000 |
commit | 891ac5e256beff387c5a745dc912f221cc17024e (patch) | |
tree | bfc8c4cbc6c1f75a512e6e7d9d8b73e6b5d7de93 /usr.bin/tmux/server-window.c | |
parent | e50bf28f99a17da4b270d84d66bd20c7e271f67b (diff) |
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/server-window.c')
-rw-r--r-- | usr.bin/tmux/server-window.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c index 11f388ebded..4bc2a608f34 100644 --- a/usr.bin/tmux/server-window.c +++ b/usr.bin/tmux/server-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-window.c,v 1.4 2009/11/04 08:35:11 nicm Exp $ */ +/* $OpenBSD: server-window.c,v 1.5 2009/11/04 20:50:11 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -18,6 +18,7 @@ #include <sys/types.h> +#include <event.h> #include <unistd.h> #include "tmux.h" @@ -47,19 +48,23 @@ server_window_prepare(void) continue; events = 0; if (!server_window_backoff(wp)) - events |= POLLIN; + events = EV_READ; if (BUFFER_USED(wp->out) > 0) - events |= POLLOUT; - server_poll_add( + events |= EV_WRITE; + event_del(&wp->event); + event_set(&wp->event, wp->fd, events, server_window_callback, wp); + event_add(&wp->event, NULL); if (wp->pipe_fd == -1) continue; events = 0; if (BUFFER_USED(wp->pipe_buf) > 0) - events |= POLLOUT; - server_poll_add( + events |= EV_WRITE; + event_del(&wp->pipe_event); + event_set(&wp->pipe_event, wp->pipe_fd, events, server_window_callback, wp); + event_add(&wp->pipe_event, NULL); } } } @@ -90,7 +95,7 @@ server_window_backoff(struct window_pane *wp) /* Process a single window pane event. */ void -server_window_callback(int fd, int events, void *data) +server_window_callback(int fd, short events, void *data) { struct window_pane *wp = data; |