summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-wait-for.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-09-01 21:58:41 +0000
committernicm <nicm@openbsd.org>2014-09-01 21:58:41 +0000
commit7d5939e200e5c928004abbbeb4d921ac41b949cd (patch)
treebe7694b0ed0d748d7f939fd79843c9e066cd8553 /usr.bin/tmux/cmd-wait-for.c
parentVarious minor style and spacing nits. (diff)
downloadwireguard-openbsd-7d5939e200e5c928004abbbeb4d921ac41b949cd.tar.xz
wireguard-openbsd-7d5939e200e5c928004abbbeb4d921ac41b949cd.zip
Wake up any clients waiting with the wait-for command when the server
exits.
Diffstat (limited to 'usr.bin/tmux/cmd-wait-for.c')
-rw-r--r--usr.bin/tmux/cmd-wait-for.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.bin/tmux/cmd-wait-for.c b/usr.bin/tmux/cmd-wait-for.c
index a0678f83f8c..ea48a551670 100644
--- a/usr.bin/tmux/cmd-wait-for.c
+++ b/usr.bin/tmux/cmd-wait-for.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-wait-for.c,v 1.5 2014/09/01 21:50:18 nicm Exp $ */
+/* $OpenBSD: cmd-wait-for.c,v 1.6 2014/09/01 21:58:41 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
+ }
+}