From c933857266f195142a5bcf790e9457b4985a2f50 Mon Sep 17 00:00:00 2001 From: Nathan Straz Date: Fri, 7 Nov 2008 16:30:19 -0500 Subject: Don't wait until after the pselect to see if we're done. All the actions which need to be done before we exit are done after the pselect. Waiting until after the next pselect can cause us to sit for a second before we exit, which slows down things which use qarsh. --- qarsh.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/qarsh.c b/qarsh.c index 31ff36a..2e43658 100644 --- a/qarsh.c +++ b/qarsh.c @@ -292,13 +292,7 @@ run_remote_cmd(char *cmdline) &pselect_sigmask); if (nset == 0) { - if (cmd_finished && c_out == 0 && c_err == 0) { - /* If the command is complete and both output - * sockets are closed, we can exit now. We need - * to test all conditions at once so if none are - * true, we'll still check for heartbeat. */ - break; - } else if (!hbeat(qarsh_hb)) { + if (!hbeat(qarsh_hb)) { /* If the heartbeat fails, we should exit now. * The hbeat state will take precedence over the * exit status of the command. */ @@ -384,6 +378,13 @@ run_remote_cmd(char *cmdline) nset--; } } + if (cmd_finished && c_out == 0 && c_err == 0) { + /* If the command is complete and both output + * sockets are closed, we can exit now. We need + * to test all conditions at once so if none are + * true, we'll still check for heartbeat. */ + break; + } } if (c_out) close(c_out); if (c_err) close(c_err); -- cgit