-#if HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#endif
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#ifdef WIN32
-#if FD_SETSIZE < 512
-#define FD_SETSIZE 512
-#endif
-#include <winsock.h>
-#endif
-
-
-ZOOM_API(int)
- ZOOM_event_sys_select(int no, ZOOM_connection *cs)
-{
- struct timeval tv;
- fd_set input, output, except;
- int i, r;
- int max_fd = 0;
- int timeout = 30;
- int nfds = 0;
-
- FD_ZERO(&input);
- FD_ZERO(&output);
- FD_ZERO(&except);
-
- for (i = 0; i<no; i++)
- {
- ZOOM_connection c = cs[i];
- int fd, mask;
-
- if (!c)
- continue;
- fd = ZOOM_connection_get_socket(c);
- mask = ZOOM_connection_get_mask(c);
- timeout = ZOOM_connection_get_timeout(c);
-
- if (fd == -1)
- continue;
- if (max_fd < fd)
- max_fd = fd;
-
- if (mask & ZOOM_SELECT_READ)
- FD_SET(fd, &input);
- if (mask & ZOOM_SELECT_WRITE)
- FD_SET(fd, &output);
- if (mask & ZOOM_SELECT_EXCEPT)
- FD_SET(fd, &except);
- if (mask)
- nfds++;
- }
- if (nfds == 0)
- return 0;
-
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
-
- while ((r = select(max_fd+1, &input, &output, &except,
- (timeout == -1 ? 0 : &tv))) < 0 && errno == EINTR)
- {
- ;
- }
- if (r < 0)
- {
- yaz_log(YLOG_WARN|YLOG_ERRNO, "ZOOM_event_sys_select");
- return r;
- }
-
- for (i = 0; i<no; i++)
- {
- ZOOM_connection c = cs[i];
- int fd, mask;