diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-03-11 07:08:19 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-03-11 07:08:19 +0000 |
commit | 11ac49376a1eb3ae512d86571342c602ba50ab74 (patch) | |
tree | dca7e58d86422a8d0575fda146d07d82ee5c0353 /usr.bin/tmux/format.c | |
parent | 14e292d2be30c3b9c37fa603a6e8988b9f4df472 (diff) |
Tidy old jobs every hour instead of every 30 seconds.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 1f9c63898d8..93e653826f3 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.281 2021/03/02 10:56:45 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.282 2021/03/11 07:08:18 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -41,7 +41,6 @@ struct format_expand_state; static char *format_job_get(struct format_expand_state *, const char *); -static void format_job_timer(int, short, void *); static char *format_expand1(struct format_expand_state *, const char *); static int format_replace(struct format_expand_state *, const char *, size_t, char **, size_t *, size_t *); @@ -69,7 +68,6 @@ struct format_job { }; /* Format job tree. */ -static struct event format_job_event; static int format_job_cmp(struct format_job *, struct format_job *); static RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER(); RB_GENERATE_STATIC(format_job_tree, format_job, entry, format_job_cmp); @@ -437,30 +435,26 @@ format_job_tidy(struct format_job_tree *jobs, int force) } } -/* Remove old jobs for client. */ +/* Tidy old jobs for all clients. */ void -format_lost_client(struct client *c) -{ - if (c->jobs != NULL) - format_job_tidy(c->jobs, 1); - free(c->jobs); -} - -/* Remove old jobs periodically. */ -static void -format_job_timer(__unused int fd, __unused short events, __unused void *arg) +format_tidy_jobs(void) { struct client *c; - struct timeval tv = { .tv_sec = 60 }; format_job_tidy(&format_jobs, 0); TAILQ_FOREACH(c, &clients, entry) { if (c->jobs != NULL) format_job_tidy(c->jobs, 0); } +} - evtimer_del(&format_job_event); - evtimer_add(&format_job_event, &tv); +/* Remove old jobs for client. */ +void +format_lost_client(struct client *c) +{ + if (c->jobs != NULL) + format_job_tidy(c->jobs, 1); + free(c->jobs); } /* Wrapper for asprintf. */ @@ -3048,11 +3042,6 @@ format_create(struct client *c, struct cmdq_item *item, int tag, int flags) { struct format_tree *ft; - if (!event_initialized(&format_job_event)) { - evtimer_set(&format_job_event, format_job_timer, NULL); - format_job_timer(-1, 0, NULL); - } - ft = xcalloc(1, sizeof *ft); RB_INIT(&ft->tree); |