Braek some bits out of server_fill_client() that aren't really related to

polling into their own function.
This commit is contained in:
Nicholas Marriott 2009-10-11 00:53:14 +00:00
parent 095ecf2d90
commit f68ade7b1d

View File

@ -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. */