summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/server-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-11-04 22:43:12 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-11-04 22:43:12 +0000
commitdfb9b83ba668ae18082113a9efa8908a3c0c304a (patch)
treea0c75dd6f3030ea7c3ce4a622a78a5163d5d8904 /usr.bin/tmux/server-window.c
parent7c41588f63dd0e0c60b445558f675ed033d96e4d (diff)
Convert the window pane (pty master side) fd over to use a bufferevent.
The evbuffer API is very similar to the existing tmux buffer API so this was remarkably painless. Not many possible ways to do it, I suppose.
Diffstat (limited to 'usr.bin/tmux/server-window.c')
-rw-r--r--usr.bin/tmux/server-window.c56
1 files changed, 8 insertions, 48 deletions
diff --git a/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c
index 868437650eb..f618fa2f6ab 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.8 2009/11/04 22:02:38 nicm Exp $ */
+/* $OpenBSD: server-window.c,v 1.9 2009/11/04 22:43:11 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -30,35 +30,6 @@ int server_window_check_content(
struct session *, struct window *, struct window_pane *);
void server_window_check_alive(struct window *);
-/* Register windows for poll. */
-void
-server_window_prepare(void)
-{
- struct window *w;
- struct window_pane *wp;
- u_int i;
- int events;
-
- for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
- if ((w = ARRAY_ITEM(&windows, i)) == NULL)
- continue;
-
- TAILQ_FOREACH(wp, &w->panes, entry) {
- if (wp->fd == -1)
- continue;
- events = 0;
- if (!server_window_backoff(wp))
- events |= EV_READ;
- if (BUFFER_USED(wp->out) > 0)
- events |= EV_WRITE;
- event_del(&wp->event);
- event_set(&wp->event,
- wp->fd, events, server_window_callback, wp);
- event_add(&wp->event, NULL);
- }
- }
-}
-
/* Check if this window should suspend reading. */
int
server_window_backoff(struct window_pane *wp)
@@ -84,24 +55,6 @@ server_window_backoff(struct window_pane *wp)
return (0);
}
-/* Process a single window pane event. */
-void
-server_window_callback(int fd, short events, void *data)
-{
- struct window_pane *wp = data;
-
- if (wp->fd == -1)
- return;
-
- if (fd == wp->fd) {
- if (buffer_poll(fd, events, wp->in, wp->out) != 0) {
- close(wp->fd);
- wp->fd = -1;
- } else
- window_pane_parse(wp);
- }
-}
-
/* Window functions that need to happen every loop. */
void
server_window_loop(void)
@@ -116,6 +69,13 @@ server_window_loop(void)
if (w == NULL)
continue;
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (server_window_backoff(wp))
+ bufferevent_disable(wp->event, EV_READ);
+ else
+ bufferevent_enable(wp->event, EV_READ);
+ }
+
for (j = 0; j < ARRAY_LENGTH(&sessions); j++) {
s = ARRAY_ITEM(&sessions, j);
if (s == NULL || !session_has(s, w))