From fc92b485eac2697c63e7604a4269f438852fe044 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 26 Jan 2011 01:54:56 +0000 Subject: 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). --- usr.bin/tmux/server-client.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'usr.bin/tmux/server-client.c') diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index e8c08321aa5..62b6d9896c7 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.50 2011/01/15 00:46:19 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.51 2011/01/26 01:54:56 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -79,7 +79,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); @@ -139,8 +140,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); @@ -221,7 +223,6 @@ server_client_status_timer(void) { struct client *c; struct session *s; - struct job *job; struct timeval tv; u_int i; int interval; @@ -250,8 +251,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; } } -- cgit v1.2.3-59-g8ed1b