summaryrefslogtreecommitdiffstats
path: root/server-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-04 22:43:11 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-04 22:43:11 +0000
commita02c7e804c8c6b9984e9d09c305199ccec92763f (patch)
tree396a9d8eab87fa47c0d62e12f3ec043309a99cf1 /server-window.c
parent06ffed32169a6bf449f543803ee8b87c439ae94b (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 'server-window.c')
-rw-r--r--server-window.c54
1 files changed, 7 insertions, 47 deletions
diff --git a/server-window.c b/server-window.c
index bc6f0b4f..d0eb7960 100644
--- a/server-window.c
+++ b/server-window.c
@@ -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))