diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-02-15 15:20:03 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-02-15 15:20:03 +0000 |
commit | 3d7b8105e1385c835cf0660797fe70198097e73d (patch) | |
tree | 2e5cade8fbdbc0ce2ac112b1800224710f197af1 /server-client.c | |
parent | 3b56ebce6dd4077f6527843cfc1da63614605875 (diff) | |
download | rtmux-3d7b8105e1385c835cf0660797fe70198097e73d.tar.gz rtmux-3d7b8105e1385c835cf0660797fe70198097e73d.tar.bz2 rtmux-3d7b8105e1385c835cf0660797fe70198097e73d.zip |
Sync OpenBSD patchset 855:
Simplify the way jobs work and drop the persist type, so all jobs are
fire-and-forget.
Status jobs now managed with two trees of output (new and old), rather
than storing the output in the jobs themselves. When the status line is
processed any jobs which don't appear in the new tree are started and
the output from the old tree displayed. When a job finishes it updates
the new tree with its output and that is used for any subsequent
redraws. When the status interval expires, the new tree is moved to the
old so that all jobs are run again.
This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands
of identical persistent jobs and high memory use (this can still be
achieved by adding "sleep 30" but that is much less likely to happen by
accident).
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server-client.c b/server-client.c index 93ba0fe9..e4ca3160 100644 --- a/server-client.c +++ b/server-client.c @@ -1,4 +1,4 @@ -/* $Id: server-client.c,v 1.53 2011-01-21 23:56:53 tcunha Exp $ */ +/* $Id: server-client.c,v 1.54 2011-02-15 15:20:03 tcunha Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -78,7 +78,8 @@ server_client_create(int fd) c->tty.sy = 24; screen_init(&c->status, c->tty.sx, 1, 0); - job_tree_init(&c->status_jobs); + RB_INIT(&c->status_new); + RB_INIT(&c->status_old); c->message_string = NULL; ARRAY_INIT(&c->message_log); @@ -138,8 +139,9 @@ server_client_lost(struct client *c) if (c->stderr_event != NULL) bufferevent_free(c->stderr_event); + status_free_jobs(&c->status_new); + status_free_jobs(&c->status_old); screen_free(&c->status); - job_tree_free(&c->status_jobs); if (c->title != NULL) xfree(c->title); @@ -220,7 +222,6 @@ server_client_status_timer(void) { struct client *c; struct session *s; - struct job *job; struct timeval tv; u_int i; int interval; @@ -249,8 +250,7 @@ server_client_status_timer(void) difference = tv.tv_sec - c->status_timer.tv_sec; if (difference >= interval) { - RB_FOREACH(job, jobs, &c->status_jobs) - job_run(job); + status_update_jobs(c); c->flags |= CLIENT_STATUS; } } |