X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/ff3b058ac51e9caf5cf1fd310b8a401a97a85582..63189c10a67e72bcf6d6c6342f6b88e1aac9cd55:/src/ioset-select.c diff --git a/src/ioset-select.c b/src/ioset-select.c index 8ece128..b3d7c63 100644 --- a/src/ioset-select.c +++ b/src/ioset-select.c @@ -5,7 +5,7 @@ * * srvx is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -36,7 +36,9 @@ extern int clock_skew; static struct io_fd **fds; static unsigned int fds_size; -static fd_set read_fds, write_fds; +static fd_set read_fds; +static fd_set write_fds; +static fd_set except_fds; static int ioset_select_init(void) @@ -61,6 +63,8 @@ ioset_select_remove(struct io_fd *fd, int closed) { FD_CLR(fd->fd, &read_fds); FD_CLR(fd->fd, &write_fds); + FD_CLR(fd->fd, &except_fds); + fds[fd->fd] = NULL; (void)closed; } @@ -76,9 +80,7 @@ ioset_select_cleanup(void) free(fds); } -#if 0 -#define debug_fdsets(MSG, NFDS, READ_FDS, WRITE_FDS, EXCEPT_FDS, SELECT_TIMEOUT) (void)0 -#else +#if DEBUG_FDSETS static void debug_fdsets(const char *msg, int nfds, fd_set *read_fds, fd_set *write_fds, fd_set *except_fds, struct timeval *select_timeout) { static const char *flag_text[8] = { "---", "r", "w", "rw", "e", "er", "ew", "erw" }; @@ -87,20 +89,21 @@ debug_fdsets(const char *msg, int nfds, fd_set *read_fds, fd_set *write_fds, fd_ struct timeval now; for (pos=ii=0; iitv_sec, select_timeout->tv_usec); + log_module(MAIN_LOG, LOG_DEBUG, "%s, at %lu.%06lu:%s (timeout %lu.%06lu)", msg, (unsigned long)now.tv_sec, (unsigned long)now.tv_usec, buf, (unsigned long)select_timeout->tv_sec, (unsigned long)select_timeout->tv_usec); } else { - log_module(MAIN_LOG, LOG_DEBUG, "%s, at "FMT_TIME_T".%06ld:%s (no timeout)", msg, now.tv_sec, now.tv_usec, buf); + log_module(MAIN_LOG, LOG_DEBUG, "%s, at %lu.%06lu:%s (no timeout)", msg, (unsigned long)now.tv_sec, (unsigned long)now.tv_usec, buf); } } +#else +# define debug_fdsets(MSG, NFDS, READ_FDS, WRITE_FDS, EXCEPT_FDS, SELECT_TIMEOUT) (void)0 #endif static int @@ -114,20 +117,22 @@ ioset_select_loop(struct timeval *timeout) /* Set up read_fds and write_fds fdsets. */ FD_ZERO(&read_fds); FD_ZERO(&write_fds); + FD_ZERO(&except_fds); max_fd = -1; for (nn=0; nn