Sync OpenBSD patchset 380:

Braek some bits out of server_fill_client() that aren't really related to
polling into their own function.
This commit is contained in:
Tiago Cunha 2009-10-12 00:14:44 +00:00
parent d7fa9bc056
commit 323469723b

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.201 2009-10-12 00:12:32 tcunha Exp $ */ /* $Id: server.c,v 1.202 2009-10-12 00:14:44 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -89,6 +89,7 @@ void server_set_title(struct client *);
void server_check_timers(struct client *); void server_check_timers(struct client *);
void server_lock_server(void); void server_lock_server(void);
void server_lock_sessions(void); void server_lock_sessions(void);
void server_check_clients(void);
void server_second_timers(void); void server_second_timers(void);
int server_update_socket(void); int server_update_socket(void);
@ -372,6 +373,9 @@ server_main(int srv_fd)
sigusr1 = 0; sigusr1 = 0;
} }
/* Process client actions. */
server_check_clients();
/* Initialise pollfd array and add server socket. */ /* Initialise pollfd array and add server socket. */
server_poll_reset(); server_poll_reset();
server_poll_add(srv_fd, POLLIN); server_poll_add(srv_fd, POLLIN);
@ -596,18 +600,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. */ /* Check for general redraw on client. */
void void
server_check_redraw(struct client *c) server_check_redraw(struct client *c)
{ {
struct session *s; struct session *s = c->session;
struct window_pane *wp; struct window_pane *wp;
int flags, redraw; int flags, redraw;
if (c == NULL || c->session == NULL)
return;
s = c->session;
flags = c->tty.flags & TTY_FREEZE; flags = c->tty.flags & TTY_FREEZE;
c->tty.flags &= ~TTY_FREEZE; c->tty.flags &= ~TTY_FREEZE;
@ -667,15 +700,11 @@ server_set_title(struct client *c)
void void
server_check_timers(struct client *c) server_check_timers(struct client *c)
{ {
struct session *s; struct session *s = c->session;
struct job *job; struct job *job;
struct timeval tv; struct timeval tv;
u_int interval; u_int interval;
if (c == NULL || c->session == NULL)
return;
s = c->session;
if (gettimeofday(&tv, NULL) != 0) if (gettimeofday(&tv, NULL) != 0)
fatal("gettimeofday failed"); fatal("gettimeofday failed");
@ -713,17 +742,12 @@ void
server_fill_clients(void) server_fill_clients(void)
{ {
struct client *c; struct client *c;
struct window *w;
struct window_pane *wp;
u_int i; u_int i;
int events; int events;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i); c = ARRAY_ITEM(&clients, i);
server_check_timers(c);
server_check_redraw(c);
if (c != NULL) { if (c != NULL) {
events = 0; events = 0;
if (!(c->flags & CLIENT_BAD)) if (!(c->flags & CLIENT_BAD))
@ -741,20 +765,6 @@ server_fill_clients(void)
server_poll_add(c->tty.fd, events); 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. */ /* Fill in job fds. */