summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/server.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-10-16 17:55:14 +0000
committernicm <nicm@openbsd.org>2016-10-16 17:55:14 +0000
commit765b9a582c208af75c7304abae7e7e4c757934cb (patch)
treec6ba4d8161097c3d648fe4a1d213628591795591 /usr.bin/tmux/server.c
parentUse the err(3) family of functions more consistently. (diff)
downloadwireguard-openbsd-765b9a582c208af75c7304abae7e7e4c757934cb.tar.xz
wireguard-openbsd-765b9a582c208af75c7304abae7e7e4c757934cb.zip
Rewrite command queue handling. Each client still has a command queue,
but there is also now a global command queue. Instead of command queues being dispatched on demand from wherever the command happens to be added, they are now all dispatched from the top level server loop. Command queues may now also include callbacks as well as commands, and items may be inserted after the current command as well as at the end. This all makes command queues significantly more predictable and easier to use, and avoids the complex multiple nested command queues used by source-file, if-shell and friends. A mass rename of struct cmdq to a better name (cmdq_item probably) is coming.
Diffstat (limited to 'usr.bin/tmux/server.c')
-rw-r--r--usr.bin/tmux/server.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index d7d8f1edb6a..e5787d48f00 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.161 2016/10/15 00:01:01 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.162 2016/10/16 17:55:14 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -190,10 +190,18 @@ static int
server_loop(void)
{
struct client *c;
+ u_int items;
- server_client_loop();
notify_drain();
+ do {
+ items = cmdq_next(NULL);
+ TAILQ_FOREACH(c, &clients, entry)
+ items += cmdq_next(c);
+ } while (items != 0);
+
+ server_client_loop();
+
if (!options_get_number(global_options, "exit-unattached")) {
if (!RB_EMPTY(&sessions))
return (0);