summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server-window.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-10-28 22:53:14 +0000
committernicm <nicm@openbsd.org>2009-10-28 22:53:14 +0000
commit767eadb799e2b754a0663f41538889b2797200c6 (patch)
treea453393303495cdc326ce07d6c447c98f0eeb553 /usr.bin/tmux/server-window.c
parenttweak previous; (diff)
downloadwireguard-openbsd-767eadb799e2b754a0663f41538889b2797200c6.tar.xz
wireguard-openbsd-767eadb799e2b754a0663f41538889b2797200c6.zip
If any client currently displaying a window pane has more than 1 KB of output
buffered, don't accept any further data from the process running in the pane. This makes tmux much more responsive when flooded with output, although other buffers can still have an impact when running remotely. Prompted by a query from Ranganathan Sankaralingam.
Diffstat (limited to 'usr.bin/tmux/server-window.c')
-rw-r--r--usr.bin/tmux/server-window.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c
index 8184b0fb3ad..29d6641c9fc 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.2 2009/10/27 13:03:33 nicm Exp $ */
+/* $OpenBSD: server-window.c,v 1.3 2009/10/28 22:53:14 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -22,6 +22,7 @@
#include "tmux.h"
+int server_window_backoff(struct window_pane *);
int server_window_check_bell(struct session *, struct window *);
int server_window_check_activity(struct session *, struct window *);
int server_window_check_content(
@@ -44,7 +45,9 @@ server_window_prepare(void)
TAILQ_FOREACH(wp, &w->panes, entry) {
if (wp->fd == -1)
continue;
- events = POLLIN;
+ events = 0;
+ if (!server_window_backoff(wp))
+ events |= POLLIN;
if (BUFFER_USED(wp->out) > 0)
events |= POLLOUT;
server_poll_add(
@@ -61,6 +64,28 @@ server_window_prepare(void)
}
}
+/* Check if this window should suspend reading. */
+int
+server_window_backoff(struct window_pane *wp)
+{
+ struct client *c;
+ u_int i;
+
+ if (!window_pane_visible(wp))
+ return (0);
+
+ for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
+ c = ARRAY_ITEM(&clients, i);
+ if (c == NULL || c->session == NULL)
+ continue;
+ if (c->session->curw->window != wp->window)
+ continue;
+ if (BUFFER_USED(c->tty.out) > BACKOFF_THRESHOLD)
+ return (1);
+ }
+ return (0);
+}
+
/* Process a single window pane event. */
void
server_window_callback(int fd, int events, void *data)