=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.134 retrieving revision 1.135 diff -c -r1.134 -r1.135 *** src/usr.bin/tmux/server-client.c 2015/04/22 15:30:11 1.134 --- src/usr.bin/tmux/server-client.c 2015/04/24 23:17:11 1.135 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.134 2015/04/22 15:30:11 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.135 2015/04/24 23:17:11 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 60,66 **** server_client_create(int fd) { struct client *c; - u_int i; setblocking(fd, 0); --- 60,65 ---- *************** *** 108,120 **** evtimer_set(&c->repeat_timer, server_client_repeat_timer, c); ! for (i = 0; i < ARRAY_LENGTH(&clients); i++) { ! if (ARRAY_ITEM(&clients, i) == NULL) { ! ARRAY_SET(&clients, i, c); ! return; ! } ! } ! ARRAY_ADD(&clients, c); log_debug("new client %d", fd); } --- 107,113 ---- evtimer_set(&c->repeat_timer, server_client_repeat_timer, c); ! TAILQ_INSERT_TAIL(&clients, c, entry); log_debug("new client %d", fd); } *************** *** 148,157 **** struct message_entry *msg; u_int i; ! for (i = 0; i < ARRAY_LENGTH(&clients); i++) { ! if (ARRAY_ITEM(&clients, i) == c) ! ARRAY_SET(&clients, i, NULL); ! } log_debug("lost client %d", c->ibuf.fd); /* --- 141,147 ---- struct message_entry *msg; u_int i; ! TAILQ_REMOVE(&clients, c, entry); log_debug("lost client %d", c->ibuf.fd); /* *************** *** 205,218 **** if (event_initialized(&c->event)) event_del(&c->event); ! for (i = 0; i < ARRAY_LENGTH(&dead_clients); i++) { ! if (ARRAY_ITEM(&dead_clients, i) == NULL) { ! ARRAY_SET(&dead_clients, i, c); ! break; ! } ! } ! if (i == ARRAY_LENGTH(&dead_clients)) ! ARRAY_ADD(&dead_clients, c); c->flags |= CLIENT_DEAD; server_add_accept(0); /* may be more file descriptors now */ --- 195,201 ---- if (event_initialized(&c->event)) event_del(&c->event); ! TAILQ_INSERT_TAIL(&dead_clients, c, entry); c->flags |= CLIENT_DEAD; server_add_accept(0); /* may be more file descriptors now */ *************** *** 263,278 **** struct client *c; struct session *s; struct timeval tv; - u_int i; int interval; time_t difference; if (gettimeofday(&tv, NULL) != 0) fatal("gettimeofday failed"); ! for (i = 0; i < ARRAY_LENGTH(&clients); i++) { ! c = ARRAY_ITEM(&clients, i); ! if (c == NULL || c->session == NULL) continue; if (c->message_string != NULL || c->prompt_string != NULL) { /* --- 246,259 ---- struct client *c; struct session *s; struct timeval tv; int interval; time_t difference; if (gettimeofday(&tv, NULL) != 0) fatal("gettimeofday failed"); ! TAILQ_FOREACH(c, &clients, entry) { ! if (c->session == NULL) continue; if (c->message_string != NULL || c->prompt_string != NULL) { /* *************** *** 702,714 **** 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) ! continue; ! server_client_check_exit(c); if (c->session != NULL) { server_client_check_redraw(c); --- 683,690 ---- struct client *c; struct window *w; struct window_pane *wp; ! TAILQ_FOREACH(c, &clients, entry) { server_client_check_exit(c); if (c->session != NULL) { server_client_check_redraw(c); *************** *** 755,761 **** void server_client_check_focus(struct window_pane *wp) { - u_int i; struct client *c; int push; --- 731,736 ---- *************** *** 783,794 **** * If our window is the current window in any focused clients with an * attached session, we're focused. */ ! for (i = 0; i < ARRAY_LENGTH(&clients); i++) { ! c = ARRAY_ITEM(&clients, i); ! if (c == NULL || c->session == NULL) ! continue; ! ! if (!(c->flags & CLIENT_FOCUSED)) continue; if (c->session->flags & SESSION_UNATTACHED) continue; --- 758,765 ---- * If our window is the current window in any focused clients with an * attached session, we're focused. */ ! TAILQ_FOREACH(c, &clients, entry) { ! if (c->session == NULL || !(c->flags & CLIENT_FOCUSED)) continue; if (c->session->flags & SESSION_UNATTACHED) continue;