Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 13979 invoked from network); 10 Oct 2004 07:48:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 10 Oct 2004 07:48:31 -0000 Received: (qmail 22655 invoked by uid 500); 10 Oct 2004 07:48:28 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 22610 invoked by uid 500); 10 Oct 2004 07:48:28 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 22597 invoked by uid 99); 10 Oct 2004 07:48:27 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=HTML_FONT_BIG,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C4AE9D.A8410FBD" X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Subject: RE: Does apr_pollset_poll( ... ) block on non-blocking sockets? Date: Sun, 10 Oct 2004 09:49:21 +0200 Message-ID: <1FB4A6BBAC3AC748AFFA8E9F42A9EFBD337C84@hunt.ericom.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Does apr_pollset_poll( ... ) block on non-blocking sockets? Thread-Index: AcSptNJ1F1jhT8/IR7Kzfm66u39UrQE5344Q From: "Dror Shilo" To: "David Barrett" , X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C4AE9D.A8410FBD Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable this function has a bug on windows I have reported this bug at 8/25/2004 = but the fix did not got into ver 1.0.0: the num parameter have to return the length of descriptors=20 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=20 there for the fix for this bug is to add this line at file poll.c (*num) =3D 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 =3D NULL; } else { tv.tv_sec =3D (long)apr_time_sec(timeout); tv.tv_usec =3D (long)apr_time_usec(timeout); tvptr =3D &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 =3D pipe_select(pollset->maxfd + 1, &readset, &writeset, = &exceptset, tvptr); } else #endif rv =3D select(pollset->maxfd + 1, &readset, &writeset, &exceptset, = tvptr); (*num) =3D rv; if (rv < 0) { return apr_get_netos_error(); } if (rv =3D=3D 0) { return APR_TIMEUP; } j =3D 0; for (i =3D 0; i < pollset->nelts; i++) { apr_os_sock_t fd; if (pollset->query_set[i].desc_type =3D=3D APR_POLL_SOCKET) { fd =3D pollset->query_set[i].desc.s->socketdes; } else { #if !APR_FILES_AS_SOCKETS return APR_EBADF; #else fd =3D 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] =3D pollset->query_set[i]; pollset->result_set[j].rtnevents =3D 0; if (FD_ISSET(fd, &readset)) { pollset->result_set[j].rtnevents |=3D APR_POLLIN; } if (FD_ISSET(fd, &writeset)) { pollset->result_set[j].rtnevents |=3D APR_POLLOUT; } if (FD_ISSET(fd, &exceptset)) { pollset->result_set[j].rtnevents |=3D APR_POLLERR; } j++; } } if (descriptors) *descriptors =3D pollset->result_set; (*num) =3D j; return APR_SUCCESS; } #endif /* no poll */ Dror Shilo Ericom software -----Original Message----- From: David Barrett [mailto:dbarrett@quinthar.com] Sent: Monday, October 04, 2004 3:53 AM To: dev@apr.apache.org Subject: Does apr_pollset_poll( ... ) block on non-blocking sockets? Is the function "apr_pollset_poll( )" supposed to block, even on non-blocking sockets? I ask because I would like it to, even though it appears to not. The docs say this about the function: Block for activity on the descriptor(s) in a pollset Ideally I would like to *not* block when reading or writing, but I *do* = want to block while polling with a timeout. Am I doing something wrong, or = is it working as designed? -david=20 ------_=_NextPart_001_01C4AE9D.A8410FBD Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable RE: Does apr_pollset_poll( ... ) block on non-blocking = sockets?

this = function has a bug on windows I have reported this bug at 8/25/2004 but = the fix did not got into  ver 1.0.0:

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) =3D = j;



#else /* no = poll */

APR_DECLARE(apr_status_t) apr_pollset_poll(apr_pollset_t = *pollset,

         &nbs= p;            = ;            =          apr_interval_time_t = timeout,

         &nbs= p;            = ;            =          apr_int32_t = *num,

         &nbs= p;            = ;            =          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 =3D = NULL;

    }

    else {

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

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

        tvptr =3D = &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 =3D = pipe_select(pollset->maxfd + 1, &readset, &writeset, = &exceptset, tvptr);

    }

    else

#endif

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

    (*num) =3D rv;

    if (rv < 0) {

        return = apr_get_netos_error();

    }

    if (rv =3D=3D 0) {

        return = APR_TIMEUP;

    }

    j =3D 0;

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

        apr_os_sock_t = fd;

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

         &nbs= p;  fd =3D = pollset->query_set[i].desc.s->socketdes;

        = }

        else = {

#if = !APR_FILES_AS_SOCKETS

         &nbs= p;  return APR_EBADF;

#else

         &nbs= p;  fd =3D = pollset->query_set[i].desc.f->filedes;

#endif

        = }

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

         &nbs= p;  FD_ISSET(fd, &exceptset)) {

         &nbs= p;  pollset->result_set[j] =3D = pollset->query_set[i];

         &nbs= p;  pollset->result_set[j].rtnevents =3D 0;

         &nbs= p;  if (FD_ISSET(fd, &readset)) {

         &nbs= p;      pollset->result_set[j].rtnevents = |=3D APR_POLLIN;

         &nbs= p;  }

         &nbs= p;  if (FD_ISSET(fd, &writeset)) {

         &nbs= p;      pollset->result_set[j].rtnevents = |=3D APR_POLLOUT;

         &nbs= p;  }

         &nbs= p;  if (FD_ISSET(fd, &exceptset)) {

         &nbs= p;      pollset->result_set[j].rtnevents = |=3D APR_POLLERR;

         &nbs= p;  }

         &nbs= p;  j++;

        = }

    }

    if (descriptors)

        *descriptors = =3D pollset->result_set;

        (*num) =3D = j;

    return APR_SUCCESS;

}

#endif /* = no poll */


Dror = Shilo

Ericom = software





-----Original Message-----

From: David = Barrett [mailto:dbarrett@quinthar.com]

Sent: = Monday, October 04, 2004 3:53 AM

To: = dev@apr.apache.org

Subject: = Does apr_pollset_poll( ... ) block on non-blocking = sockets?


Is the = function "apr_pollset_poll( )" supposed to block, even = on

non-blocking sockets?  I ask because I would like it = to, even though it

appears to = not.  The docs say this about the function:

        Block for activity on the descriptor(s) in a = pollset

Ideally I = would like to *not* block when reading or writing, but I *do* = want

to block = while polling with a timeout.  Am I doing something wrong, or is = it

working as = designed?

-david =

------_=_NextPart_001_01C4AE9D.A8410FBD--