From a54a88edd6fd893d4370feb9f9136e13096b891c Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 1 Jun 2020 09:43:00 +0000 Subject: Instead of sending all data to control mode clients as fast as possible, add a limit of how much data will be sent to the client and try to use it for panes with some degree of fairness. GitHub issue 2217, with George Nachman. --- cmd-capture-pane.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'cmd-capture-pane.c') diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index 588b0fd5..6f37bc8f 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -214,15 +214,20 @@ cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item) return (CMD_RETURN_ERROR); if (args_has(args, 'p')) { - if (!file_can_print(c)) { - cmdq_error(item, "can't write output to client"); + if (len > 0 && buf[len - 1] == '\n') + len--; + if (c->flags & CLIENT_CONTROL) + control_write(c, "%.*s", (int)len, buf); + else { + if (!file_can_print(c)) { + cmdq_error(item, "can't write to client"); + free(buf); + return (CMD_RETURN_ERROR); + } + file_print_buffer(c, buf, len); + file_print(c, "\n"); free(buf); - return (CMD_RETURN_ERROR); } - file_print_buffer(c, buf, len); - if (args_has(args, 'P') && len > 0) - file_print(c, "\n"); - free(buf); } else { bufname = NULL; if (args_has(args, 'b')) -- cgit