the num parameter have to return the length of descriptors

the select call returns the total number of socket handles that are ready and contained in the fd_set  structures

therefore if we have 2 socket that one have an FD_READ and the second have FD_READ and FD_WRITE it will return 3 , but the lenght of descriptors is only 2 , this is a bug

there for the fix for this bug is to add this  line at file poll.c

(*num) = j;



#else /* no poll */

APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t *pollset,

                                           apr_interval_time_t timeout,

                                           apr_int32_t *num,

                                           const apr_pollfd_t **descriptors)

{

    int rv;

    apr_uint32_t i, j;

    struct timeval tv, *tvptr;

    fd_set readset, writeset, exceptset;

    if (timeout < 0) {

        tvptr = NULL;

    }

    else {

        tv.tv_sec = (long)apr_time_sec(timeout);

        tv.tv_usec = (long)apr_time_usec(timeout);

        tvptr = &tv;

    }

    memcpy(&readset, &(pollset->readset), sizeof(fd_set));

    memcpy(&writeset, &(pollset->writeset), sizeof(fd_set));

    memcpy(&exceptset, &(pollset->exceptset), sizeof(fd_set));

#ifdef NETWARE

    if (HAS_PIPES(pollset->set_type)) {

        rv = pipe_select(pollset->maxfd + 1, &readset, &writeset, &exceptset, tvptr);

    }

    else

#endif

    rv = select(pollset->maxfd + 1, &readset, &writeset, &exceptset, tvptr);

    (*num) = rv;

    if (rv < 0) {

        return apr_get_netos_error();

    }

    if (rv == 0) {

        return APR_TIMEUP;

    }

    j = 0;

    for (i = 0; i < pollset->nelts; i++) {

        apr_os_sock_t fd;

        if (pollset->query_set[i].desc_type == APR_POLL_SOCKET) {

            fd = pollset->query_set[i].desc.s->socketdes;

        }

        else {

#if !APR_FILES_AS_SOCKETS

            return APR_EBADF;

#else

            fd = pollset->query_set[i].desc.f->filedes;

#endif

        }

        if (FD_ISSET(fd, &readset) || FD_ISSET(fd, &writeset) ||

            FD_ISSET(fd, &exceptset)) {

            pollset->result_set[j] = pollset->query_set[i];

            pollset->result_set[j].rtnevents = 0;

            if (FD_ISSET(fd, &readset)) {

                pollset->result_set[j].rtnevents |= APR_POLLIN;

            }

            if (FD_ISSET(fd, &writeset)) {

                pollset->result_set[j].rtnevents |= APR_POLLOUT;

            }

            if (FD_ISSET(fd, &exceptset)) {

                pollset->result_set[j].rtnevents |= APR_POLLERR;

            }

            j++;

        }

    }

    if (descriptors)

        *descriptors = pollset->result_set;

        (*num) = j;

    return APR_SUCCESS;

}

#endif /* no poll */


Dror Shilo

Ericom software