From b205eeea9a183d68cdcb874dfaea1e0f99249ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 6 Mar 2014 12:58:15 +0100 Subject: [PATCH] Don't wait for clients to be present inorder to read program I/O Previously the underlying application would block on I/O because we would wait to read it until a client is connected to display the information. This prevented long running tasks from making progress. However with the new approach output data of programs which terminate while no client is connected is lost. --- server.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server.c b/server.c index 892baa9..df01f35 100644 --- a/server.c +++ b/server.c @@ -225,10 +225,8 @@ static void server_mainloop() { if (FD_ISSET(server.socket, &readfds)) server_accept_client(now); - if (FD_ISSET(server.pty, &readfds)) { + if (FD_ISSET(server.pty, &readfds)) pty_data = server_read_pty(&server.pty_output); - clients_ready = !pty_data; - } for (Client **prev_next = &server.clients, *c = server.clients; c;) { if (c->state == STATE_DISCONNECTED) { @@ -297,7 +295,7 @@ static void server_mainloop() { c = c->next; } - if (clients_ready && server.clients && server.running) + if (server.running && clients_ready) FD_SET_MAX(server.pty, &new_readfds, new_fdmax); if (FD_ISSET(server.pty, &writefds)) {