summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-11-04 23:12:44 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-11-04 23:12:44 +0000
commit948d8365576ad37dbb34cd3630c5d60eeb7e270f (patch)
tree70009e10a9025cb6b5b43614621cc5503a677d33 /usr.bin
parent52dd67fa64f919338f816fe41b47e9afb8e14657 (diff)
Don't reenlist the client imsg event every loop, instead have a small function
to it and call it after the event triggers or after a imsg is added.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/server-client.c30
-rw-r--r--usr.bin/tmux/server-fn.c18
-rw-r--r--usr.bin/tmux/server.c8
-rw-r--r--usr.bin/tmux/tmux.h4
4 files changed, 26 insertions, 34 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 61c85367180..87c723ad915 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.13 2009/11/04 21:47:42 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.14 2009/11/04 23:12:43 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -61,6 +61,7 @@ server_client_create(int fd)
c = xcalloc(1, sizeof *c);
c->references = 0;
imsg_init(&c->ibuf, fd);
+ server_update_event(c);
if (gettimeofday(&c->creation_time, NULL) != 0)
fatal("gettimeofday failed");
@@ -150,30 +151,6 @@ server_client_lost(struct client *c)
recalculate_sizes();
}
-/* Register clients for poll. */
-void
-server_client_prepare(void)
-{
- struct client *c;
- u_int i;
- int events;
-
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- if ((c = ARRAY_ITEM(&clients, i)) == NULL)
- continue;
-
- events = 0;
- if (!(c->flags & CLIENT_BAD))
- events |= EV_READ;
- if (c->ibuf.w.queued > 0)
- events |= EV_WRITE;
- event_del(&c->event);
- event_set(&c->event,
- c->ibuf.fd, events, server_client_callback, c);
- event_add(&c->event, NULL);
- }
-}
-
/* Process a single client event. */
void
server_client_callback(int fd, short events, void *data)
@@ -196,7 +173,8 @@ server_client_callback(int fd, short events, void *data)
if (events & EV_READ && server_client_msg_dispatch(c) != 0)
goto client_lost;
}
-
+
+ server_update_event(c);
return;
client_lost:
diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c
index bfcc8111b1d..4c026b6df0b 100644
--- a/usr.bin/tmux/server-fn.c
+++ b/usr.bin/tmux/server-fn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-fn.c,v 1.26 2009/10/11 10:39:27 nicm Exp $ */
+/* $OpenBSD: server-fn.c,v 1.27 2009/11/04 23:12:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -59,6 +59,7 @@ server_write_client(
return;
log_debug("writing %d to client %d", type, c->ibuf.fd);
imsg_compose(ibuf, type, PROTOCOL_VERSION, -1, -1, (void *) buf, len);
+ server_update_event(c);
}
void
@@ -371,3 +372,18 @@ server_clear_identify(struct client *c)
server_redraw_client(c);
}
}
+
+void
+server_update_event(struct client *c)
+{
+ short events;
+
+ events = 0;
+ if (!(c->flags & CLIENT_BAD))
+ events |= EV_READ;
+ if (c->ibuf.w.queued > 0)
+ events |= EV_WRITE;
+ event_del(&c->event);
+ event_set(&c->event, c->ibuf.fd, events, server_client_callback, c);
+ event_add(&c->event, NULL);
+}
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 4dd19e66968..e8c0b7dd0fa 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.70 2009/11/04 22:47:34 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.71 2009/11/04 23:12:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -160,11 +160,11 @@ server_start(char *path)
log_debug("socket path %s", socket_path);
setproctitle("server (%s)", rpathbuf);
+ event_init();
+
server_fd = server_create_socket();
server_client_create(pair[1]);
- event_init();
-
if (access(SYSTEM_CFG, R_OK) == 0) {
if (load_cfg(SYSTEM_CFG, NULL, &cause) != 0)
goto error;
@@ -215,8 +215,6 @@ server_loop(void)
while (!server_should_shutdown()) {
server_update_socket();
- server_client_prepare();
-
event_loopexit(&tv);
event_loop(EVLOOP_ONCE);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 39b9c27da84..5899be357d1 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.164 2009/11/04 22:44:53 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.165 2009/11/04 23:12:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1564,7 +1564,6 @@ void server_signal_clear(void);
/* server-client.c */
void server_client_create(int);
void server_client_lost(struct client *);
-void server_client_prepare(void);
void server_client_callback(int, short, void *);
void server_client_loop(void);
@@ -1598,6 +1597,7 @@ void server_destroy_session_group(struct session *);
void server_destroy_session(struct session *);
void server_set_identify(struct client *);
void server_clear_identify(struct client *);
+void server_update_event(struct client *);
/* status.c */
int status_redraw(struct client *);