summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-08-28 11:38:27 +0000
committernicm <nicm@openbsd.org>2015-08-28 11:38:27 +0000
commit03e2b84e8cf40844b0182285d2ebe0ba332ae80d (patch)
treec26672290c9e8dcde0ac8b190a6a688c7ee053a3
parentRename 'part_blkno' to 'sector' as it has not held DEV_BSIZE values in (diff)
downloadwireguard-openbsd-03e2b84e8cf40844b0182285d2ebe0ba332ae80d.tar.xz
wireguard-openbsd-03e2b84e8cf40844b0182285d2ebe0ba332ae80d.zip
Move format job cleanup onto its own timer.
-rw-r--r--usr.bin/tmux/format.c19
-rw-r--r--usr.bin/tmux/server.c4
-rw-r--r--usr.bin/tmux/tmux.h3
3 files changed, 19 insertions, 7 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index f3031ce3ce5..04592fc0921 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.76 2015/08/28 10:06:52 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.77 2015/08/28 11:38:27 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -37,6 +37,7 @@
void format_job_callback(struct job *);
const char *format_job_get(struct format_tree *, const char *);
+void format_job_timer(int, short, void *);
int format_replace(struct format_tree *, const char *, size_t, char **,
size_t *, size_t *);
@@ -63,6 +64,7 @@ struct format_job {
};
/* Format job tree. */
+struct event format_job_event;
int format_job_cmp(struct format_job *, struct format_job *);
RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER();
RB_PROTOTYPE(format_job_tree, format_job, entry, format_job_cmp);
@@ -191,6 +193,8 @@ format_job_callback(struct job *job)
server_status_client(c);
fj->status = 0;
}
+
+ log_debug("%s: %s: %s", __func__, fj->cmd, fj->out);
}
/* Find a job. */
@@ -226,10 +230,11 @@ format_job_get(struct format_tree *ft, const char *cmd)
/* Remove old jobs. */
void
-format_clean(void)
+format_job_timer(unused int fd, unused short events, unused void *arg)
{
struct format_job *fj, *fj1;
time_t now;
+ struct timeval tv = { .tv_sec = 60 };
now = time(NULL);
RB_FOREACH_SAFE(fj, format_job_tree, &format_jobs, fj1) {
@@ -237,6 +242,8 @@ format_clean(void)
continue;
RB_REMOVE(format_job_tree, &format_jobs, fj);
+ log_debug("%s: %s", __func__, fj->cmd);
+
if (fj->job != NULL)
job_free(fj->job);
@@ -245,6 +252,9 @@ format_clean(void)
free(fj);
}
+
+ evtimer_del(&format_job_event);
+ evtimer_add(&format_job_event, &tv);
}
/* Create a new tree. */
@@ -261,6 +271,11 @@ format_create_status(int status)
struct format_tree *ft;
char host[HOST_NAME_MAX + 1], *ptr;
+ 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);
ft->status = status;
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 1c95a6f7ba2..d0b266636eb 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.129 2015/07/20 15:50:04 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.130 2015/08/28 11:38:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -522,8 +522,6 @@ server_second_callback(unused int fd, unused short events, unused void *arg)
server_client_status_timer();
- format_clean();
-
evtimer_del(&server_ev_second);
memset(&tv, 0, sizeof tv);
tv.tv_sec = 1;
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 9f5d8b81d27..812f5e4ed91 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.532 2015/08/28 07:49:24 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.533 2015/08/28 11:38:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1449,7 +1449,6 @@ void cfg_show_causes(struct session *);
/* format.c */
struct format_tree;
-void format_clean(void);
struct format_tree *format_create(void);
struct format_tree *format_create_status(int);
void format_free(struct format_tree *);