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 /cmd-wait-for.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 'cmd-wait-for.c')
-rw-r--r-- | cmd-wait-for.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cmd-wait-for.c b/cmd-wait-for.c index 3654d4e5..48a6fe3c 100644 --- a/cmd-wait-for.c +++ b/cmd-wait-for.c @@ -194,3 +194,25 @@ cmd_wait_for_unlock(struct cmd_q *cmdq, const char *name, return (CMD_RETURN_NORMAL); } +void +cmd_wait_for_flush(void) +{ + struct wait_channel *wc, *wc1; + struct cmd_q *wq, *wq1; + + RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) { + TAILQ_FOREACH_SAFE(wq, &wc->waiters, waitentry, wq1) { + TAILQ_REMOVE(&wc->waiters, wq, waitentry); + if (!cmdq_free(wq)) + cmdq_continue(wq); + } + while ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) { + TAILQ_REMOVE(&wc->lockers, wq, waitentry); + if (!cmdq_free(wq)) + cmdq_continue(wq); + } + RB_REMOVE(wait_channels, &wait_channels, wc); + free((void *)wc->name); + free(wc); + } +} |