mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Move format job cleanup onto its own timer.
This commit is contained in:
parent
ee9f708500
commit
b6618b631b
17
format.c
17
format.c
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
void format_job_callback(struct job *);
|
void format_job_callback(struct job *);
|
||||||
const char *format_job_get(struct format_tree *, const char *);
|
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 **,
|
int format_replace(struct format_tree *, const char *, size_t, char **,
|
||||||
size_t *, size_t *);
|
size_t *, size_t *);
|
||||||
@ -63,6 +64,7 @@ struct format_job {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Format job tree. */
|
/* Format job tree. */
|
||||||
|
struct event format_job_event;
|
||||||
int format_job_cmp(struct format_job *, struct format_job *);
|
int format_job_cmp(struct format_job *, struct format_job *);
|
||||||
RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER();
|
RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER();
|
||||||
RB_PROTOTYPE(format_job_tree, format_job, entry, format_job_cmp);
|
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);
|
server_status_client(c);
|
||||||
fj->status = 0;
|
fj->status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_debug("%s: %s: %s", __func__, fj->cmd, fj->out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find a job. */
|
/* Find a job. */
|
||||||
@ -226,10 +230,11 @@ format_job_get(struct format_tree *ft, const char *cmd)
|
|||||||
|
|
||||||
/* Remove old jobs. */
|
/* Remove old jobs. */
|
||||||
void
|
void
|
||||||
format_clean(void)
|
format_job_timer(unused int fd, unused short events, unused void *arg)
|
||||||
{
|
{
|
||||||
struct format_job *fj, *fj1;
|
struct format_job *fj, *fj1;
|
||||||
time_t now;
|
time_t now;
|
||||||
|
struct timeval tv = { .tv_sec = 60 };
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
RB_FOREACH_SAFE(fj, format_job_tree, &format_jobs, fj1) {
|
RB_FOREACH_SAFE(fj, format_job_tree, &format_jobs, fj1) {
|
||||||
@ -237,6 +242,8 @@ format_clean(void)
|
|||||||
continue;
|
continue;
|
||||||
RB_REMOVE(format_job_tree, &format_jobs, fj);
|
RB_REMOVE(format_job_tree, &format_jobs, fj);
|
||||||
|
|
||||||
|
log_debug("%s: %s", __func__, fj->cmd);
|
||||||
|
|
||||||
if (fj->job != NULL)
|
if (fj->job != NULL)
|
||||||
job_free(fj->job);
|
job_free(fj->job);
|
||||||
|
|
||||||
@ -245,6 +252,9 @@ format_clean(void)
|
|||||||
|
|
||||||
free(fj);
|
free(fj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evtimer_del(&format_job_event);
|
||||||
|
evtimer_add(&format_job_event, &tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new tree. */
|
/* Create a new tree. */
|
||||||
@ -261,6 +271,11 @@ format_create_status(int status)
|
|||||||
struct format_tree *ft;
|
struct format_tree *ft;
|
||||||
char host[HOST_NAME_MAX + 1], *ptr;
|
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);
|
ft = xcalloc(1, sizeof *ft);
|
||||||
RB_INIT(&ft->tree);
|
RB_INIT(&ft->tree);
|
||||||
ft->status = status;
|
ft->status = status;
|
||||||
|
2
server.c
2
server.c
@ -522,8 +522,6 @@ server_second_callback(unused int fd, unused short events, unused void *arg)
|
|||||||
|
|
||||||
server_client_status_timer();
|
server_client_status_timer();
|
||||||
|
|
||||||
format_clean();
|
|
||||||
|
|
||||||
evtimer_del(&server_ev_second);
|
evtimer_del(&server_ev_second);
|
||||||
memset(&tv, 0, sizeof tv);
|
memset(&tv, 0, sizeof tv);
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
|
1
tmux.h
1
tmux.h
@ -1449,7 +1449,6 @@ void cfg_show_causes(struct session *);
|
|||||||
|
|
||||||
/* format.c */
|
/* format.c */
|
||||||
struct format_tree;
|
struct format_tree;
|
||||||
void format_clean(void);
|
|
||||||
struct format_tree *format_create(void);
|
struct format_tree *format_create(void);
|
||||||
struct format_tree *format_create_status(int);
|
struct format_tree *format_create_status(int);
|
||||||
void format_free(struct format_tree *);
|
void format_free(struct format_tree *);
|
||||||
|
Loading…
Reference in New Issue
Block a user