X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fzoom-socket.c;h=92998843d80e138b88920e1294f06d22144afa8c;hb=cf30376bd9e43ad653c6292f275ee4dd10b70a6c;hp=fc1df84fccedd989d69c85a4c9ce5ee8819a3cef;hpb=5b851cf1bb19aea8448630ac6f179e53d8847e57;p=yaz-moved-to-github.git diff --git a/src/zoom-socket.c b/src/zoom-socket.c index fc1df84..9299884 100644 --- a/src/zoom-socket.c +++ b/src/zoom-socket.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: zoom-socket.c,v 1.3 2007-02-28 11:14:56 mike Exp $ + * $Id: zoom-socket.c,v 1.7 2007-11-10 08:59:31 adam Exp $ */ /** * \file zoom-socket.c @@ -23,126 +23,18 @@ #if HAVE_SYS_TIME_H #include #endif -#if HAVE_SYS_POLL_H -#include -#endif -#if HAVE_SYS_SELECT_H -#include -#endif -#ifdef WIN32 -#if FD_SETSIZE < 512 -#define FD_SETSIZE 512 -#endif -#include -#endif - - -/* - * Note that ZOOM_event_sys_select() is limited as to how many file - * descriptors it can multiplex due to its use of select() which in - * turn uses the statically defined fd_set type to be a bitmap of the - * file descriptors to check. On Ubuntu 6.06 (and almost certainly on - * Debian, and probably on all Linuxes, and maybe all Unixes) this is - * by default set to 1024 (though it may be possible to override this - * using a #define before including -- I've not tried - * this). 1024 file descriptors is a lot, but not enough in all - * cases, e.g. when running IRSpy on a large target database. So you - * should ensure that YAZ uses ZOOM_event_sys_poll() when possible. - */ -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 - 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= 0) { - ZOOM_connection c = poll_cs[i]; - if (r) + for (i = 0; i < nfds; i++) { - int mask = 0; - if (pollfds[i].revents & POLLIN) - mask += ZOOM_SELECT_READ; - if (pollfds[i].revents & POLLOUT) - mask += ZOOM_SELECT_WRITE; - if (pollfds[i].revents & POLLERR) - mask += ZOOM_SELECT_EXCEPT; - ZOOM_connection_fire_event_socket(c, mask); + ZOOM_connection c = yp[i].client_data; + enum yaz_poll_mask output_mask = yp[i].output_mask; + if (output_mask & yaz_poll_timeout) + ZOOM_connection_fire_event_timeout(c); + else + { + int mask = 0; + if (output_mask & yaz_poll_read) + mask += ZOOM_SELECT_READ; + if (output_mask & yaz_poll_write) + mask += ZOOM_SELECT_WRITE; + if (output_mask & yaz_poll_except) + mask += ZOOM_SELECT_EXCEPT; + ZOOM_connection_fire_event_socket(c, mask); + } } - else - ZOOM_connection_fire_event_timeout(c); } - xfree(pollfds); - xfree(poll_cs); + xfree(yp); return r; } -#endif ZOOM_API(int) ZOOM_event(int no, ZOOM_connection *cs) @@ -221,11 +102,8 @@ ZOOM_API(int) r = ZOOM_event_nonblock(no, cs); if (r) return r; -#if HAVE_SYS_POLL_H - ZOOM_event_sys_poll(no, cs); -#else - ZOOM_event_sys_select(no, cs); -#endif + while (ZOOM_event_sys_yaz_poll(no, cs) < 0 && errno == EINTR) + ; return ZOOM_event_nonblock(no, cs); }