summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-05-31 20:04:15 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-05-31 20:04:15 +0000
commit5569ff9723fcacb0e0206f02adbb4b85368bc1bf (patch)
tree76f9b0f74c209069e484a89554b66234ba40452f /server.c
parentabe745f99126838079e8d70318983a3b66356573 (diff)
Don't hang when window closes early; also add lots more debugging.
Diffstat (limited to 'server.c')
-rw-r--r--server.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/server.c b/server.c
index 89e5970b..dcd115f3 100644
--- a/server.c
+++ b/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