From: sgunderson Date: Thu, 17 Aug 2000 22:59:14 +0000 (+0000) Subject: process_all_clients(): Fixed a bug (reporting and much tracing by Sean MacLennan... X-Git-Url: https://git.sesse.net/?p=betaftpd;a=commitdiff_plain;h=85c74b6283f53e8deeab46354a4d3971039b6d56 process_all_clients(): Fixed a bug (reporting and much tracing by Sean MacLennan ) where the server could refuse to send a reply on a finished uploading when using poll() mode, and generally not handle both POLLHUP/ERR and POLLIN at the same time. --- diff --git a/ftpd.c b/ftpd.c index 4d65210..757c109 100644 --- a/ftpd.c +++ b/ftpd.c @@ -579,11 +579,7 @@ int process_all_clients(const fd_set * const active_clients, const int num_ac) c = next; next = c->next_conn; #if HAVE_POLL - if (fds[c->sock].revents & (POLLERR|POLLHUP|POLLNVAL)) { - destroy_conn(c); - continue; - } - if (!fds[c->sock].revents & POLLIN) { + if (!fds[c->sock].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) { continue; } #else @@ -603,8 +599,10 @@ int process_all_clients(const fd_set * const active_clients, const int num_ac) * client has closed the socket. If we get a return value * of -1 (error), we close the socket ourselves. * - * Just to be safe, we include this code for poll() as - * well. + * We do the same for poll(), even though we actually have + * bits that tell us what is happening (in case of new + * input AND error/hangup at the same time, we do an + * explicit check at the bottom of the loop as well). */ destroy_conn(c); continue; @@ -619,6 +617,11 @@ int process_all_clients(const fd_set * const active_clients, const int num_ac) c->buf_len += bytes_avail; parse_command(c); + + if (fds[c->sock].revents & (POLLERR|POLLHUP|POLLNVAL)) { + destroy_conn(c); + continue; + } } return checked_through; }