aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-12 00:12:33 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-12 00:12:33 +0000
commitd7fa9bc056be2bc89af85825ffc6e6144759a806 (patch)
tree64bd55becedefe7d8fb3a24708f7ec7385366f9a
parent256a55b33b812ca1ecd03149f879828a960592fe (diff)
downloadrtmux-d7fa9bc056be2bc89af85825ffc6e6144759a806.tar.gz
rtmux-d7fa9bc056be2bc89af85825ffc6e6144759a806.tar.bz2
rtmux-d7fa9bc056be2bc89af85825ffc6e6144759a806.zip
Sync OpenBSD patchset 379:
Put all jobs on a global all_jobs list and use that in server.c instead of running through all the clients.
-rw-r--r--job.c8
-rw-r--r--server.c40
-rw-r--r--tmux.h6
3 files changed, 15 insertions, 39 deletions
diff --git a/job.c b/job.c
index d5b2c389..df53c736 100644
--- a/job.c
+++ b/job.c
@@ -1,4 +1,4 @@
-/* $Id: job.c,v 1.2 2009-10-11 23:59:34 tcunha Exp $ */
+/* $Id: job.c,v 1.3 2009-10-12 00:12:32 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,6 +29,9 @@
* output.
*/
+/* All jobs list. */
+struct joblist all_jobs = SLIST_HEAD_INITIALIZER(&all_jobs);
+
RB_GENERATE(jobs, job, entry, job_cmp);
int
@@ -66,6 +69,7 @@ job_tree_free(struct jobs *jobs)
while (!RB_EMPTY(jobs)) {
job = RB_ROOT(jobs);
RB_REMOVE(jobs, jobs, job);
+ SLIST_REMOVE(&all_jobs, job, job, lentry);
job_free(job);
}
}
@@ -89,6 +93,7 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd,
job = xmalloc(sizeof *job);
job->cmd = xstrdup(cmd);
+ job->pid = -1;
job->client = c;
@@ -100,6 +105,7 @@ job_add(struct jobs *jobs, struct client *c, const char *cmd,
job->data = data;
RB_INSERT(jobs, jobs, job);
+ SLIST_INSERT_HEAD(&all_jobs, job, lentry);
return (job);
}
diff --git a/server.c b/server.c
index 19166887..4dcd89c7 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.200 2009-10-11 23:55:26 tcunha Exp $ */
+/* $Id: server.c,v 1.201 2009-10-12 00:12:32 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -72,9 +72,7 @@ void server_handle_windows(void);
void server_fill_clients(void);
void server_handle_clients(void);
void server_fill_jobs(void);
-void server_fill_jobs1(struct jobs *);
void server_handle_jobs(void);
-void server_handle_jobs1(struct jobs *);
void server_accept_client(int);
void server_handle_client(struct client *);
void server_handle_window(struct window *, struct window_pane *);
@@ -417,11 +415,7 @@ server_main(int srv_fd)
/* Set window names. */
set_window_names();
- /*
- * Handle window and client sockets. Clients can create
- * windows, so windows must come first to avoid messing up by
- * increasing the array size.
- */
+ /* Handle window and client sockets. */
server_handle_jobs();
server_handle_windows();
server_handle_clients();
@@ -767,22 +761,9 @@ server_fill_clients(void)
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;
- RB_FOREACH(job, jobs, jobs) {
+ SLIST_FOREACH(job, &all_jobs, lentry) {
if (job->fd == -1)
continue;
server_poll_add(job->fd, POLLIN);
@@ -793,23 +774,10 @@ server_fill_jobs1(struct jobs *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 pollfd *pfd;
- RB_FOREACH(job, jobs, jobs) {
+ SLIST_FOREACH(job, &all_jobs, lentry) {
if (job->fd == -1)
continue;
if ((pfd = server_poll_lookup(job->fd)) == NULL)
diff --git a/tmux.h b/tmux.h
index 0ce17340..8a5c09a9 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.465 2009-10-12 00:08:12 tcunha Exp $ */
+/* $Id: tmux.h,v 1.466 2009-10-12 00:12:33 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -576,8 +576,10 @@ struct job {
void *data;
RB_ENTRY(job) entry;
+ SLIST_ENTRY(job) lentry;
};
RB_HEAD(jobs, job);
+SLIST_HEAD(joblist, job);
/* Screen selection. */
struct screen_sel {
@@ -1197,7 +1199,7 @@ struct options_entry *options_set_data(
void *options_get_data(struct options *, const char *);
/* job.c */
-extern struct jobs jobs_tree;
+extern struct joblist all_jobs;
int job_cmp(struct job *, struct job *);
RB_PROTOTYPE(jobs, job, entry, job_cmp);
void job_tree_init(struct jobs *);