apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bnicho...@apache.org
Subject cvs commit: apr/poll/unix poll.c
Date Fri, 02 Aug 2002 20:49:02 GMT
bnicholes    2002/08/02 13:49:02

  Modified:    poll/unix poll.c
  Log:
  NetWare can't handle mixed descriptor sets.  Added code to make sure that
  the set contain only socket or pipe descriptors.
  
  Revision  Changes    Path
  1.23      +55 -4     apr/poll/unix/poll.c
  
  Index: poll.c
  ===================================================================
  RCS file: /home/cvs/apr/poll/unix/poll.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- poll.c	2 Aug 2002 20:41:58 -0000	1.22
  +++ poll.c	2 Aug 2002 20:49:02 -0000	1.23
  @@ -65,6 +65,11 @@
   #include <sys/poll.h>
   #endif
   
  +#ifdef NETWARE
  +#define HAS_SOCKETS(dt) (dt == APR_POLL_SOCKET) ? 1 : 0
  +#define HAS_PIPES(dt) (dt == APR_POLL_FILE) ? 1 : 0
  +#endif
  +
   #ifdef HAVE_POLL    /* We can just use poll to do our socket polling. */
   
   static apr_int16_t get_event(apr_int16_t event)
  @@ -186,7 +191,7 @@
       int maxfd = -1;
       struct timeval tv, *tvptr;
   #ifdef NETWARE
  -    int is_pipe = 0;
  +    apr_datatype_e set_type = APR_NO_DESC;
   #endif
   
       if (timeout < 0) {
  @@ -206,16 +211,30 @@
           apr_os_sock_t fd;
   
           if (aprset[i].desc_type == APR_POLL_SOCKET) {
  +#ifdef NETWARE
  +            if (HAS_PIPES(set_type)) {
  +                return APR_EBADF;
  +            }
  +            else {
  +                set_type = APR_POLL_SOCKET;
  +            }
  +#endif
               fd = aprset[i].desc.s->socketdes;
           }
           else {
   #if !APR_FILES_AS_SOCKETS
               return APR_EBADF;
   #else
  -            fd = aprset[i].desc.f->filedes;
   #ifdef NETWARE
  -            is_pipe = aprset[i].desc.f->is_pipe;
  +            if (aprset[i].desc.f->is_pipe && !HAS_SOCKETS(set_type)) {
  +                set_type = APR_POLL_FILE;
  +            }
  +            else
  +                return APR_EBADF;
   #endif /* NETWARE */
  +
  +            fd = aprset[i].desc.f->filedes;
  +
   #endif /* APR_FILES_AS_SOCKETS */
           }
           if (aprset[i].reqevents & APR_POLLIN) {
  @@ -234,7 +253,7 @@
       }
   
   #ifdef NETWARE
  -    if (is_pipe) {
  +    if (HAS_PIPES(set_type)) {
           rv = pipe_select(maxfd + 1, &readset, &writeset, &exceptset, tvptr);
       }
       else {
  @@ -297,6 +316,9 @@
       apr_pollfd_t *query_set;
       apr_pollfd_t *result_set;
       apr_pool_t *pool;
  +#ifdef NETWARE
  +    int set_type;
  +#endif
   };
   
   APR_DECLARE(apr_status_t) apr_pollset_create(apr_pollset_t **pollset,
  @@ -313,6 +335,9 @@
       FD_ZERO(&((*pollset)->writeset));
       FD_ZERO(&((*pollset)->exceptset));
       (*pollset)->maxfd = 0;
  +#ifdef NETWARE
  +    (*pollset)->set_type = APR_NO_DESC;
  +#endif
   #endif
       (*pollset)->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
       (*pollset)->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
  @@ -352,14 +377,34 @@
       pollset->pollset[pollset->nelts].events = get_event(descriptor->reqevents);
   #else
       if (descriptor->desc_type == APR_POLL_SOCKET) {
  +#ifdef NETWARE
  +        /* NetWare can't handle mixed descriptor types in select() */
  +        if (HAS_PIPES(pollset->set_type)) {
  +            return APR_EBADF;
  +        }
  +        else {
  +            pollset->set_type = APR_POLL_SOCKET;
  +        }
  +#endif
           fd = descriptor->desc.s->socketdes;
       }
       else {
   #if !APR_FILES_AS_SOCKETS
           return APR_EBADF;
   #else
  +#ifdef NETWARE
  +        /* NetWare can't handle mixed descriptor types in select() */
  +        if (descriptor->desc.f->is_pipe && !HAS_SOCKETS(pollset->set_type))
{
  +            pollset->set_type = APR_POLL_FILE;
  +            fd = descriptor->desc.f->filedes;
  +        }
  +        else {
  +            return APR_EBADF;
  +        }
  +#else
           fd = descriptor->desc.f->filedes;
   #endif
  +#endif
       }
       if (descriptor->reqevents & APR_POLLIN) {
           FD_SET(fd, &(pollset->readset));
  @@ -505,6 +550,12 @@
       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;
  
  
  

Mime
View raw message