diff options
author | nicm <nicm> | 2014-09-01 21:58:41 +0000 |
---|---|---|
committer | nicm <nicm> | 2014-09-01 21:58:41 +0000 |
commit | 733cea8847fadf922e239f05b4cdd8afc2f6c943 (patch) | |
tree | 8273712155d2e673155af469e5cf562de137ae35 /server.c | |
parent | 4e956d545a52fe6b8310cfb30a26a89976d55cd9 (diff) | |
download | rtmux-733cea8847fadf922e239f05b4cdd8afc2f6c943.tar.gz rtmux-733cea8847fadf922e239f05b4cdd8afc2f6c943.tar.bz2 rtmux-733cea8847fadf922e239f05b4cdd8afc2f6c943.zip |
Wake up any clients waiting with the wait-for command when the server
exits.
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -217,16 +217,30 @@ server_loop(void) int server_should_shutdown(void) { - u_int i; + struct client *c; + u_int i; if (!options_get_number(&global_options, "exit-unattached")) { if (!RB_EMPTY(&sessions)) return (0); } + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c != NULL && c->session != NULL) + return (0); + } + + /* + * No attached clients therefore want to exit - flush any waiting + * clients but don't actually exit until they've gone. + */ + cmd_wait_for_flush(); for (i = 0; i < ARRAY_LENGTH(&clients); i++) { if (ARRAY_ITEM(&clients, i) != NULL) return (0); } + return (1); } @@ -238,6 +252,8 @@ server_send_shutdown(void) struct session *s, *next_s; u_int i; + cmd_wait_for_flush(); + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); if (c != NULL) { |