mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 06:17:04 +00:00
Don't hang when window closes early; also add lots more debugging.
This commit is contained in:
14
server.c
14
server.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server.c,v 1.44 2007-12-06 09:46:23 nicm Exp $ */
|
||||
/* $Id: server.c,v 1.45 2008-05-31 20:04:15 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -153,12 +153,14 @@ server_main(const char *srv_path, int srv_fd)
|
||||
server_fill_clients(&pfd);
|
||||
|
||||
/* Do the poll. */
|
||||
if (poll(pfds, nfds, INFTIM) == -1) {
|
||||
log_debug("polling %d fds", nfds);
|
||||
if ((nfds = poll(pfds, nfds, INFTIM)) == -1) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
continue;
|
||||
fatal("poll failed");
|
||||
}
|
||||
pfd = pfds;
|
||||
log_debug("poll returned %d", nfds);
|
||||
|
||||
/* Handle server socket. */
|
||||
if (pfd->revents & (POLLERR|POLLNVAL|POLLHUP))
|
||||
@ -215,6 +217,7 @@ server_fill_windows(struct pollfd **pfd)
|
||||
(*pfd)->events = POLLIN;
|
||||
if (BUFFER_USED(w->out) > 0)
|
||||
(*pfd)->events |= POLLOUT;
|
||||
log_debug("adding window %d (%d)", (*pfd)->fd, w->fd);
|
||||
}
|
||||
(*pfd)++;
|
||||
}
|
||||
@ -229,6 +232,7 @@ server_handle_windows(struct pollfd **pfd)
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
|
||||
if ((w = ARRAY_ITEM(&windows, i)) != NULL) {
|
||||
log_debug("testing window %d (%d)", (*pfd)->fd, w->fd);
|
||||
if (buffer_poll(*pfd, w->in, w->out) != 0)
|
||||
server_lost_window(w);
|
||||
else
|
||||
@ -255,16 +259,18 @@ server_fill_clients(struct pollfd **pfd)
|
||||
(*pfd)->events = POLLIN;
|
||||
if (BUFFER_USED(c->out) > 0)
|
||||
(*pfd)->events |= POLLOUT;
|
||||
log_debug("adding client %d (%d)", (*pfd)->fd, c->fd);
|
||||
}
|
||||
(*pfd)++;
|
||||
|
||||
if (c == NULL || c->tty.fd == -1)
|
||||
if (c == NULL || c->tty.fd == -1 || c->session == NULL)
|
||||
(*pfd)->fd = -1;
|
||||
else {
|
||||
(*pfd)->fd = c->tty.fd;
|
||||
(*pfd)->events = POLLIN;
|
||||
if (BUFFER_USED(c->tty.out) > 0)
|
||||
(*pfd)->events |= POLLOUT;
|
||||
log_debug("adding tty %d (%d)", (*pfd)->fd, c->tty.fd);
|
||||
}
|
||||
(*pfd)++;
|
||||
}
|
||||
@ -281,6 +287,7 @@ server_handle_clients(struct pollfd **pfd)
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
|
||||
if (c != NULL) {
|
||||
log_debug("testing client %d (%d)", (*pfd)->fd, c->fd);
|
||||
if (buffer_poll(*pfd, c->in, c->out) != 0) {
|
||||
server_lost_client(c);
|
||||
(*pfd) += 2;
|
||||
@ -291,6 +298,7 @@ server_handle_clients(struct pollfd **pfd)
|
||||
(*pfd)++;
|
||||
|
||||
if (c != NULL && c->tty.fd != -1 && c->session != NULL) {
|
||||
log_debug("testing tty %d (%d)", (*pfd)->fd, c->tty.fd);
|
||||
if (buffer_poll(*pfd, c->tty.in, c->tty.out) != 0)
|
||||
server_lost_client(c);
|
||||
else
|
||||
|
Reference in New Issue
Block a user