src/poll.c
int yaz_poll_select(struct yaz_poll_fd *fds, int num_fds, int sec, int nsec)
{
    struct timeval tv;
    fd_set input, output, except;
    int i, r;
    int max_fd = 0;

    FD_ZERO(&input);
    FD_ZERO(&output);
    FD_ZERO(&except);

    assert(num_fds >= 0);
    for (i = 0; i < num_fds; i++)
    {
        enum yaz_poll_mask mask = fds[i].input_mask;
        int fd = fds[i].fd;

        /* Timeout events */
        if (fd < 0)
            continue;

        if (mask & yaz_poll_read)
            FD_SET(fd, &input);
        if (mask & yaz_poll_write)
            FD_SET(fd, &output);
        if (mask & yaz_poll_except)
            FD_SET(fd, &except);
        if (max_fd < fd)
            max_fd = fd;
    }
    tv.tv_sec = sec;
    tv.tv_usec = nsec / 1000;

    r = select(max_fd+1, &input, &output, &except, (sec == -1 ? 0 : &tv));
    if (r >= 0)
    {
        for (i = 0; i < num_fds; i++)
        {
            enum yaz_poll_mask mask = yaz_poll_none;
            int fd = fds[i].fd;
            if (!r)
                yaz_poll_add(mask, yaz_poll_timeout);
            else if (fd >= 0) {
                if (FD_ISSET(fd, &input))
                    yaz_poll_add(mask, yaz_poll_read);
                if (FD_ISSET(fd, &output))
                    yaz_poll_add(mask, yaz_poll_write);
                if (FD_ISSET(fd, &except))
                    yaz_poll_add(mask, yaz_poll_except);
            }
            fds[i].output_mask = mask;
        }
    }
    return r;
}
/*
  Note that yaz_poll_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 <sys/select.h> -- 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_yaz_poll_poll() when possible.
*/
Note that yaz_poll_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_yaz_poll_poll() when possible.
Note that yaz_poll_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_yaz_poll_poll () when possible .
int yaz_poll_select(struct yaz_poll_fd *fds, int num_fds, int sec, int nsec)
{
    struct timeval tv;
    fd_set input, output, except;
    int i, r;
    int max_fd = 0;
    FD_ZERO(&input);
    FD_ZERO(&output);
    FD_ZERO(&except);
    assert(num_fds >= 0);
    for (i = 0; i < num_fds; i++)
    {
        enum yaz_poll_mask mask = fds[i].input_mask;
        int fd = fds[i].fd;
        if (fd < 0)
            continue;
        if (mask & yaz_poll_read)
            FD_SET(fd, &input);
        if (mask & yaz_poll_write)
            FD_SET(fd, &output);
        if (mask & yaz_poll_except)
            FD_SET(fd, &except);
        if (max_fd < fd)
            max_fd = fd;
    }
    tv.tv_sec = sec;
    tv.tv_usec = nsec / 1000;
    r = select(max_fd+1, &input, &output, &except, (sec == -1 ? 0 : &tv));
    if (r >= 0)
    {
        for (i = 0; i < num_fds; i++)
        {
            enum yaz_poll_mask mask = yaz_poll_none;
            int fd = fds[i].fd;
            if (!r)
                yaz_poll_add(mask, yaz_poll_timeout);
            else if (fd >= 0) {
                if (FD_ISSET(fd, &input))
                    yaz_poll_add(mask, yaz_poll_read);
                if (FD_ISSET(fd, &output))
                    yaz_poll_add(mask, yaz_poll_write);
                if (FD_ISSET(fd, &except))
                    yaz_poll_add(mask, yaz_poll_except);
            }
            fds[i].output_mask = mask;
        }
    }
    return r;
}
int yaz_poll_select ( struct yaz_poll_fd * fds , int num_fds , int sec , int nsec ) { struct timeval tv ; fd_set input , output , except ; int i , r ; int max_fd = 0 ; FD_ZERO ( & input ) ; FD_ZERO ( & output ) ; FD_ZERO ( & except ) ; assert ( num_fds >= 0 ) ; for ( i = 0 ; i < num_fds ; i ++ ) { enum yaz_poll_mask mask = fds [ i ] . input_mask ; int fd = fds [ i ] . fd ; if ( fd < 0 ) continue ; if ( mask & yaz_poll_read ) FD_SET ( fd , & input ) ; if ( mask & yaz_poll_write ) FD_SET ( fd , & output ) ; if ( mask & yaz_poll_except ) FD_SET ( fd , & except ) ; if ( max_fd < fd ) max_fd = fd ; } tv . tv_sec = sec ; tv . tv_usec = nsec / 1000 ; r = select ( max_fd + 1 , & input , & output , & except , ( sec == -1 ? 0 : & tv ) ) ; if ( r >= 0 ) { for ( i = 0 ; i < num_fds ; i ++ ) { enum yaz_poll_mask mask = yaz_poll_none ; int fd = fds [ i ] . fd ; if ( ! r ) yaz_poll_add ( mask , yaz_poll_timeout ) ; else if ( fd >= 0 ) { if ( FD_ISSET ( fd , & input ) ) yaz_poll_add ( mask , yaz_poll_read ) ; if ( FD_ISSET ( fd , & output ) ) yaz_poll_add ( mask , yaz_poll_write ) ; if ( FD_ISSET ( fd , & except ) ) yaz_poll_add ( mask , yaz_poll_except ) ; } fds [ i ] . output_mask = mask ; } } return r ; }
Note that yaz_poll_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.
Note that yaz_poll_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 .
/* Timeout events */