aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2016-02-08 17:08:10 -0600
committerPeter Seebach <peter.seebach@windriver.com>2016-02-08 17:08:10 -0600
commitb73342cfa3be4dc4a6b960f44e5181ab655b16bd (patch)
tree81f298fe3196c78b1abfc561afa984707165c32d
parent2932b9e1319c4a376f52ffe8c160685165a2fbaa (diff)
downloadpseudo-b73342cfa3be4dc4a6b960f44e5181ab655b16bd.tar.gz
pseudo-b73342cfa3be4dc4a6b960f44e5181ab655b16bd.tar.bz2
pseudo-b73342cfa3be4dc4a6b960f44e5181ab655b16bd.zip
pseudo_server.c: increase "short" timeout, improve logic for shutdowns
Only cancel shutdown if a client showed up. Change timeout from 1 second to 3 seconds, so it gets at least one time through the loop.
-rw-r--r--ChangeLog.txt1
-rw-r--r--pseudo_server.c16
2 files changed, 10 insertions, 7 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index f191020..404923f 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,5 +1,6 @@
2016-02-08:
* (seebs) require -S to shutdown server when running a command.
+ * (seebs) improve logic for server shutdowns, increase short timeout
2016-02-05:
* (seebs) don't abort search for server on first try.
diff --git a/pseudo_server.c b/pseudo_server.c
index 56fbbc4..4ceaa47 100644
--- a/pseudo_server.c
+++ b/pseudo_server.c
@@ -58,7 +58,8 @@ pseudo_client_t *clients;
static int active_clients = 0, highest_client = 0, max_clients = 0;
#define LOOP_DELAY 2
-int pseudo_server_timeout = 30;
+#define DEFAULT_PSEUDO_SERVER_TIMEOUT 30
+int pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
static int die_peacefully = 0;
static int die_forcefully = 0;
@@ -345,7 +346,7 @@ serve_client(int i) {
}
in->pathlen = (s - response_path) + 1;
/* exit quickly once clients go away, though */
- pseudo_server_timeout = 1;
+ pseudo_server_timeout = 3;
} else {
in->type = PSEUDO_MSG_ACK;
in->pathlen = 0;
@@ -481,12 +482,13 @@ pseudo_server_loop(void) {
if ((fd = accept(listen_fd, (struct sockaddr *) &client, &len)) != -1) {
pseudo_debug(PDBGF_SERVER, "new client fd %d\n", fd);
open_client(fd);
+ /* A new client implicitly cancels any
+ * previous shutdown request, or a
+ * shutdown for lack of clients.
+ */
+ pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT;
+ die_peacefully = 0;
}
- /* A new client implicitly cancels a previous
- * shutdown request.
- */
- pseudo_server_timeout = 30;
- die_peacefully = 0;
}
pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients);
}