diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-11 00:53:15 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-10-11 00:53:15 +0000 |
commit | 7725e9ef55bcc1310ebe04518dc7f61cc669af90 (patch) | |
tree | 2389b4fea53c0b9059bd93746c6000d25c8a0bfe | |
parent | f0c86baf5b05be079e2dfe9f7a06e34f6585dd84 (diff) |
Braek some bits out of server_fill_client() that aren't really related to
polling into their own function.
-rw-r--r-- | usr.bin/tmux/server.c | 76 |
1 files changed, 43 insertions, 33 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index 27bee8b9450..d649876440f 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.50 2009/10/10 18:42:14 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.51 2009/10/11 00:53:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -90,6 +90,7 @@ void server_set_title(struct client *); void server_check_timers(struct client *); void server_lock_server(void); void server_lock_sessions(void); +void server_check_clients(void); void server_second_timers(void); int server_update_socket(void); @@ -369,6 +370,9 @@ server_main(int srv_fd) sigusr1 = 0; } + /* Process client actions. */ + server_check_clients(); + /* Initialise pollfd array and add server socket. */ server_poll_reset(); server_poll_add(srv_fd, POLLIN); @@ -593,18 +597,47 @@ server_handle_windows(void) } } +/* Check clients for redraw and timers. */ +void +server_check_clients(void) +{ + struct client *c; + struct window *w; + struct window_pane *wp; + u_int i; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + + server_check_timers(c); + server_check_redraw(c); + } + + /* + * Clear any window redraw flags (will have been redrawn as part of + * client). + */ + for (i = 0; i < ARRAY_LENGTH(&windows); i++) { + w = ARRAY_ITEM(&windows, i); + if (w == NULL) + continue; + + w->flags &= ~WINDOW_REDRAW; + TAILQ_FOREACH(wp, &w->panes, entry) + wp->flags &= ~PANE_REDRAW; + } +} + /* Check for general redraw on client. */ void server_check_redraw(struct client *c) { - struct session *s; + struct session *s = c->session; struct window_pane *wp; int flags, redraw; - if (c == NULL || c->session == NULL) - return; - s = c->session; - flags = c->tty.flags & TTY_FREEZE; c->tty.flags &= ~TTY_FREEZE; @@ -664,15 +697,11 @@ server_set_title(struct client *c) void server_check_timers(struct client *c) { - struct session *s; + struct session *s = c->session; struct job *job; struct timeval tv; u_int interval; - if (c == NULL || c->session == NULL) - return; - s = c->session; - if (gettimeofday(&tv, NULL) != 0) fatal("gettimeofday failed"); @@ -709,18 +738,13 @@ server_check_timers(struct client *c) void server_fill_clients(void) { - struct client *c; - struct window *w; - struct window_pane *wp; - u_int i; - int events; + struct client *c; + u_int i; + int events; for (i = 0; i < ARRAY_LENGTH(&clients); i++) { c = ARRAY_ITEM(&clients, i); - server_check_timers(c); - server_check_redraw(c); - if (c != NULL) { events = 0; if (!(c->flags & CLIENT_BAD)) @@ -738,20 +762,6 @@ server_fill_clients(void) server_poll_add(c->tty.fd, events); } } - - /* - * Clear any window redraw flags (will have been redrawn as part of - * client). - */ - for (i = 0; i < ARRAY_LENGTH(&windows); i++) { - w = ARRAY_ITEM(&windows, i); - if (w == NULL) - continue; - - w->flags &= ~WINDOW_REDRAW; - TAILQ_FOREACH(wp, &w->panes, entry) - wp->flags &= ~PANE_REDRAW; - } } /* Fill in job fds. */ |