mirror of
https://github.com/tmux/tmux.git
synced 2025-04-22 12:28:48 +00:00
Put all jobs on a global all_jobs list and use that in server.c instead of
running through all the clients.
This commit is contained in:
parent
b7c364a853
commit
095ecf2d90
6
job.c
6
job.c
@ -30,6 +30,9 @@
|
|||||||
* output.
|
* output.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* All jobs list. */
|
||||||
|
struct joblist all_jobs = SLIST_HEAD_INITIALIZER(&all_jobs);
|
||||||
|
|
||||||
RB_GENERATE(jobs, job, entry, job_cmp);
|
RB_GENERATE(jobs, job, entry, job_cmp);
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -67,6 +70,7 @@ job_tree_free(struct jobs *jobs)
|
|||||||
while (!RB_EMPTY(jobs)) {
|
while (!RB_EMPTY(jobs)) {
|
||||||
job = RB_ROOT(jobs);
|
job = RB_ROOT(jobs);
|
||||||
RB_REMOVE(jobs, jobs, job);
|
RB_REMOVE(jobs, jobs, job);
|
||||||
|
SLIST_REMOVE(&all_jobs, job, job, lentry);
|
||||||
job_free(job);
|
job_free(job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +94,7 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd,
|
|||||||
|
|
||||||
job = xmalloc(sizeof *job);
|
job = xmalloc(sizeof *job);
|
||||||
job->cmd = xstrdup(cmd);
|
job->cmd = xstrdup(cmd);
|
||||||
|
job->pid = -1;
|
||||||
|
|
||||||
job->client = c;
|
job->client = c;
|
||||||
|
|
||||||
@ -101,6 +106,7 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd,
|
|||||||
job->data = data;
|
job->data = data;
|
||||||
|
|
||||||
RB_INSERT(jobs, jobs, job);
|
RB_INSERT(jobs, jobs, job);
|
||||||
|
SLIST_INSERT_HEAD(&all_jobs, job, lentry);
|
||||||
|
|
||||||
return (job);
|
return (job);
|
||||||
}
|
}
|
||||||
|
38
server.c
38
server.c
@ -73,9 +73,7 @@ void server_handle_windows(void);
|
|||||||
void server_fill_clients(void);
|
void server_fill_clients(void);
|
||||||
void server_handle_clients(void);
|
void server_handle_clients(void);
|
||||||
void server_fill_jobs(void);
|
void server_fill_jobs(void);
|
||||||
void server_fill_jobs1(struct jobs *);
|
|
||||||
void server_handle_jobs(void);
|
void server_handle_jobs(void);
|
||||||
void server_handle_jobs1(struct jobs *);
|
|
||||||
void server_accept_client(int);
|
void server_accept_client(int);
|
||||||
void server_handle_client(struct client *);
|
void server_handle_client(struct client *);
|
||||||
void server_handle_window(struct window *, struct window_pane *);
|
void server_handle_window(struct window *, struct window_pane *);
|
||||||
@ -414,11 +412,7 @@ server_main(int srv_fd)
|
|||||||
/* Set window names. */
|
/* Set window names. */
|
||||||
set_window_names();
|
set_window_names();
|
||||||
|
|
||||||
/*
|
/* Handle window and client sockets. */
|
||||||
* Handle window and client sockets. Clients can create
|
|
||||||
* windows, so windows must come first to avoid messing up by
|
|
||||||
* increasing the array size.
|
|
||||||
*/
|
|
||||||
server_handle_jobs();
|
server_handle_jobs();
|
||||||
server_handle_windows();
|
server_handle_windows();
|
||||||
server_handle_clients();
|
server_handle_clients();
|
||||||
@ -763,23 +757,10 @@ server_fill_clients(void)
|
|||||||
/* Fill in job fds. */
|
/* Fill in job fds. */
|
||||||
void
|
void
|
||||||
server_fill_jobs(void)
|
server_fill_jobs(void)
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c != NULL)
|
|
||||||
server_fill_jobs1(&c->status_jobs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
server_fill_jobs1(struct jobs *jobs)
|
|
||||||
{
|
{
|
||||||
struct job *job;
|
struct job *job;
|
||||||
|
|
||||||
RB_FOREACH(job, jobs, jobs) {
|
SLIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
if (job->fd == -1)
|
if (job->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
server_poll_add(job->fd, POLLIN);
|
server_poll_add(job->fd, POLLIN);
|
||||||
@ -789,24 +770,11 @@ server_fill_jobs1(struct jobs *jobs)
|
|||||||
/* Handle job fds. */
|
/* Handle job fds. */
|
||||||
void
|
void
|
||||||
server_handle_jobs(void)
|
server_handle_jobs(void)
|
||||||
{
|
|
||||||
struct client *c;
|
|
||||||
u_int i;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
|
||||||
c = ARRAY_ITEM(&clients, i);
|
|
||||||
if (c != NULL)
|
|
||||||
server_handle_jobs1(&c->status_jobs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
server_handle_jobs1(struct jobs *jobs)
|
|
||||||
{
|
{
|
||||||
struct job *job;
|
struct job *job;
|
||||||
struct pollfd *pfd;
|
struct pollfd *pfd;
|
||||||
|
|
||||||
RB_FOREACH(job, jobs, jobs) {
|
SLIST_FOREACH(job, &all_jobs, lentry) {
|
||||||
if (job->fd == -1)
|
if (job->fd == -1)
|
||||||
continue;
|
continue;
|
||||||
if ((pfd = server_poll_lookup(job->fd)) == NULL)
|
if ((pfd = server_poll_lookup(job->fd)) == NULL)
|
||||||
|
4
tmux.h
4
tmux.h
@ -578,8 +578,10 @@ struct job {
|
|||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
RB_ENTRY(job) entry;
|
RB_ENTRY(job) entry;
|
||||||
|
SLIST_ENTRY(job) lentry;
|
||||||
};
|
};
|
||||||
RB_HEAD(jobs, job);
|
RB_HEAD(jobs, job);
|
||||||
|
SLIST_HEAD(joblist, job);
|
||||||
|
|
||||||
/* Screen selection. */
|
/* Screen selection. */
|
||||||
struct screen_sel {
|
struct screen_sel {
|
||||||
@ -1199,7 +1201,7 @@ struct options_entry *options_set_data(
|
|||||||
void *options_get_data(struct options *, const char *);
|
void *options_get_data(struct options *, const char *);
|
||||||
|
|
||||||
/* job.c */
|
/* job.c */
|
||||||
extern struct jobs jobs_tree;
|
extern struct joblist all_jobs;
|
||||||
int job_cmp(struct job *, struct job *);
|
int job_cmp(struct job *, struct job *);
|
||||||
RB_PROTOTYPE(jobs, job, entry, job_cmp);
|
RB_PROTOTYPE(jobs, job, entry, job_cmp);
|
||||||
void job_tree_init(struct jobs *);
|
void job_tree_init(struct jobs *);
|
||||||
|
Loading…
Reference in New Issue
Block a user