You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by gs...@apache.org on 2003/11/17 02:41:18 UTC

cvs commit: apr/support/unix waitio.c

gstein      2003/11/16 17:41:18

  Modified:    file_io/os2 filedup.c open.c pipe.c
               file_io/unix filedup.c open.c pipe.c
               file_io/win32 filedup.c open.c pipe.c
               include  apr_support.h
               include/arch/netware apr_arch_file_io.h
               include/arch/os2 apr_arch_file_io.h apr_arch_networkio.h
               include/arch/unix apr_arch_file_io.h apr_arch_networkio.h
               include/arch/win32 apr_arch_file_io.h apr_arch_networkio.h
               network_io/beos sendrecv.c
               network_io/os2 sockets.c
               network_io/unix sockets.c
               network_io/win32 sockets.c
               support/unix waitio.c
  Log:
  With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
  needed to be rebuilt. Specifically, it needs a pollset, but we don't want
  to allocate that all the time. Thus, we need to create it once at socket
  or file creation time, and then reuse that pollset.
  
  NOTE: this makes the library compile, but some of the test programs may
  not. I have also not verified this work yet (in favor of just getting it
  to at least compile...)
  
  For the apr_arch_*.h files, I added a pollset member to the file and
  socket structures.
  
  For the various open/dup/etc functions, I added the creation of that
  pollset whenever a file or socket is created.
  (I may have missed some and will verify further)
  
  For the socket create and sendrecv function, I added the creation of the
  pollset.
  (again, may have missed some, but if everybody uses alloc_socket, then we
   should be okay)
  
  * support/unix/waitio.c: rebuild in terms of the pollset
  
  Revision  Changes    Path
  1.33      +9 -0      apr/file_io/os2/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/filedup.c,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- filedup.c	7 Jan 2003 00:52:51 -0000	1.32
  +++ filedup.c	17 Nov 2003 01:41:17 -0000	1.33
  @@ -96,6 +96,10 @@
           *new_file = dup_file;
       }
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   }
   
  @@ -158,5 +162,10 @@
       old_file->filedes = -1;
       apr_pool_cleanup_kill(old_file->pool, (void *)old_file,
                             apr_file_cleanup);
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   }
  
  
  
  1.60      +9 -0      apr/file_io/os2/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/open.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- open.c	2 Mar 2003 03:11:22 -0000	1.59
  +++ open.c	17 Nov 2003 01:41:17 -0000	1.60
  @@ -144,6 +144,10 @@
       dafile->direction = 0;
       dafile->pipe = FALSE;
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&dafile->pollset, 1, cont, 0);
  +
       if (!(flag & APR_FILE_NOCLEANUP)) { 
           apr_pool_cleanup_register(dafile->pool, dafile, apr_file_cleanup, apr_file_cleanup);
       }
  @@ -239,6 +243,11 @@
           if (rv)
               return rv;
       }
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, cont, 0);
  +
       return APR_SUCCESS;
   }    
   
  
  
  
  1.42      +3 -0      apr/file_io/os2/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/os2/pipe.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- pipe.c	26 Oct 2003 23:22:16 -0000	1.41
  +++ pipe.c	17 Nov 2003 01:41:17 -0000	1.42
  @@ -123,6 +123,7 @@
       (*in)->pipe = 1;
       (*in)->timeout = -1;
       (*in)->blocking = BLK_ON;
  +    (void) apr_pollset_create(&(*in)->pollset, 1, pool, 0);
       apr_pool_cleanup_register(pool, *in, apr_file_cleanup, apr_pool_cleanup_null);
   
       (*out) = (apr_file_t *)apr_palloc(pool, sizeof(apr_file_t));
  @@ -135,6 +136,7 @@
       (*out)->pipe = 1;
       (*out)->timeout = -1;
       (*out)->blocking = BLK_ON;
  +    (void) apr_pollset_create(&(*out)->pollset, 1, pool, 0);
       apr_pool_cleanup_register(pool, *out, apr_file_cleanup, apr_pool_cleanup_null);
   
       return APR_SUCCESS;
  @@ -196,6 +198,7 @@
       (*file)->blocking = BLK_UNKNOWN; /* app needs to make a timeout call */
       (*file)->timeout = -1;
       (*file)->filedes = *thefile;
  +    (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0);
   
       if (register_cleanup) {
           apr_pool_cleanup_register(pool, *file, apr_file_cleanup,
  
  
  
  1.64      +9 -0      apr/file_io/unix/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/filedup.c,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- filedup.c	22 Mar 2003 02:33:50 -0000	1.63
  +++ filedup.c	17 Nov 2003 01:41:17 -0000	1.64
  @@ -131,6 +131,10 @@
                                 apr_unix_file_cleanup, 
                                 apr_unix_file_cleanup);
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   }
   
  @@ -183,5 +187,10 @@
       old_file->filedes = -1;
       apr_pool_cleanup_kill(old_file->pool, (void *)old_file,
                             apr_unix_file_cleanup);
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   }
  
  
  
  1.112     +4 -0      apr/file_io/unix/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/open.c,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- open.c	19 Mar 2003 03:45:42 -0000	1.111
  +++ open.c	17 Nov 2003 01:41:17 -0000	1.112
  @@ -189,6 +189,10 @@
       (*new)->dataRead = 0;
       (*new)->direction = 0;
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, pool, 0);
  +
       if (!(flag & APR_FILE_NOCLEANUP)) {
           apr_pool_cleanup_register((*new)->pool, (void *)(*new), 
                                     apr_unix_file_cleanup, 
  
  
  
  1.65      +6 -0      apr/file_io/unix/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/unix/pipe.c,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- pipe.c	26 Oct 2003 23:22:16 -0000	1.64
  +++ pipe.c	17 Nov 2003 01:41:17 -0000	1.65
  @@ -198,6 +198,10 @@
                                     apr_unix_file_cleanup,
                                     apr_pool_cleanup_null);
       }
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0);
       return APR_SUCCESS;
   }
   
  @@ -229,6 +233,7 @@
   #if APR_HAS_THREADS
       (*in)->thlock = NULL;
   #endif
  +    (void) apr_pollset_create(&(*in)->pollset, 1, pool, 0);
   
       (*out) = (apr_file_t *)apr_pcalloc(pool, sizeof(apr_file_t));
       (*out)->pool = pool;
  @@ -242,6 +247,7 @@
   #if APR_HAS_THREADS
       (*out)->thlock = NULL;
   #endif
  +    (void) apr_pollset_create(&(*out)->pollset, 1, pool, 0);
   
       apr_pool_cleanup_register((*in)->pool, (void *)(*in), apr_unix_file_cleanup,
                            apr_pool_cleanup_null);
  
  
  
  1.56      +9 -0      apr/file_io/win32/filedup.c
  
  Index: filedup.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/filedup.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- filedup.c	19 Sep 2003 18:07:04 -0000	1.55
  +++ filedup.c	17 Nov 2003 01:41:17 -0000	1.56
  @@ -86,6 +86,10 @@
       apr_pool_cleanup_register((*new_file)->pool, (void *)(*new_file), file_cleanup,
                           apr_pool_cleanup_null);
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   #endif /* !defined(_WIN32_WCE) */
   }
  @@ -190,5 +194,10 @@
       old_file->filehand = INVALID_HANDLE_VALUE;
       apr_pool_cleanup_kill(old_file->pool, (void *)old_file,
                             file_cleanup);
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new_file)->pollset, 1, p, 0);
  +
       return APR_SUCCESS;
   }
  
  
  
  1.119     +8 -0      apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.118
  retrieving revision 1.119
  diff -u -r1.118 -r1.119
  --- open.c	7 Jul 2003 22:44:10 -0000	1.118
  +++ open.c	17 Nov 2003 01:41:17 -0000	1.119
  @@ -436,6 +436,10 @@
           }
       }
   
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, cont, 0);
  +
       if (!(flag & APR_FILE_NOCLEANUP)) {
           apr_pool_cleanup_register((*new)->pool, (void *)(*new), file_cleanup,
                                     apr_pool_cleanup_null);
  @@ -574,6 +578,10 @@
               return rv;
           }
       }
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*file)->pollset, 1, pool, 0);
   
       /* XXX... we pcalloc above so all others are zeroed.
        * Should we be testing if thefile is a handle to 
  
  
  
  1.52      +2 -0      apr/file_io/win32/pipe.c
  
  Index: pipe.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/pipe.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- pipe.c	24 Jan 2003 18:22:13 -0000	1.51
  +++ pipe.c	17 Nov 2003 01:41:17 -0000	1.52
  @@ -148,6 +148,7 @@
       (*in)->dataRead = 0;
       (*in)->direction = 0;
       (*in)->pOverlapped = NULL;
  +    (void) apr_pollset_create(&(*in)->pollset, 1, p, 0);
   
       (*out) = (apr_file_t *)apr_pcalloc(p, sizeof(apr_file_t));
       (*out)->pool = p;
  @@ -161,6 +162,7 @@
       (*out)->dataRead = 0;
       (*out)->direction = 0;
       (*out)->pOverlapped = NULL;
  +    (void) apr_pollset_create(&(*out)->pollset, 1, p, 0);
   
       if (apr_os_level >= APR_WIN_NT) {
           /* Create the read end of the pipe */
  
  
  
  1.5       +2 -0      apr/include/apr_support.h
  
  Index: apr_support.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_support.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apr_support.h	5 Mar 2003 21:22:26 -0000	1.4
  +++ apr_support.h	17 Nov 2003 01:41:17 -0000	1.5
  @@ -76,6 +76,8 @@
   
   /**
    * Wait for IO to occur or timeout.
  + *
  + * Uses POOL for temporary allocations.
    */
   apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
                                           int for_read);
  
  
  
  1.3       +4 -0      apr/include/arch/netware/apr_arch_file_io.h
  
  Index: apr_arch_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/netware/apr_arch_file_io.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- apr_arch_file_io.h	2 Oct 2003 14:48:45 -0000	1.2
  +++ apr_arch_file_io.h	17 Nov 2003 01:41:17 -0000	1.3
  @@ -63,6 +63,7 @@
   #include "apr_file_info.h"
   #include "apr_errno.h"
   #include "apr_lib.h"
  +#include "apr_poll.h"
   
   /* System headers the file I/O library needs */
   #if APR_HAVE_FCNTL_H
  @@ -119,6 +120,9 @@
       int buffered;
       enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
       int ungetchar;    /* Last char provided by an unget op. (-1 = no char)*/
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   
       /* Stuff for buffered mode */
       char *buffer;
  
  
  
  1.2       +4 -0      apr/include/arch/os2/apr_arch_file_io.h
  
  Index: apr_arch_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/os2/apr_arch_file_io.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- apr_arch_file_io.h	7 Jan 2003 00:52:54 -0000	1.1
  +++ apr_arch_file_io.h	17 Nov 2003 01:41:17 -0000	1.2
  @@ -61,6 +61,7 @@
   #include "apr_file_io.h"
   #include "apr_file_info.h"
   #include "apr_errno.h"
  +#include "apr_poll.h"
   
   /* We have an implementation of mkstemp but it's not very multi-threading 
    * friendly & is part of the POSIX emulation rather than native so don't
  @@ -82,6 +83,9 @@
       int pipe;
       HEV pipeSem;
       enum { BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   
       /* Stuff for buffered mode */
       char *buffer;
  
  
  
  1.5       +5 -0      apr/include/arch/os2/apr_arch_networkio.h
  
  Index: apr_arch_networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/os2/apr_arch_networkio.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apr_arch_networkio.h	2 Nov 2003 20:51:18 -0000	1.4
  +++ apr_arch_networkio.h	17 Nov 2003 01:41:17 -0000	1.5
  @@ -59,6 +59,8 @@
   #include "apr_network_io.h"
   #include "apr_general.h"
   #include "apr_arch_os2calls.h"
  +#include "apr_poll.h"
  +
   #if APR_HAVE_NETDB_H
   #include <netdb.h>
   #endif
  @@ -85,6 +87,9 @@
       apr_int32_t options;
       apr_int32_t inherit;
       sock_userdata_t *userdata;
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   };
   
   /* Error codes returned from sock_errno() */
  
  
  
  1.4       +4 -0      apr/include/arch/unix/apr_arch_file_io.h
  
  Index: apr_arch_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/apr_arch_file_io.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_arch_file_io.h	16 Feb 2003 21:59:08 -0000	1.3
  +++ apr_arch_file_io.h	17 Nov 2003 01:41:17 -0000	1.4
  @@ -64,6 +64,7 @@
   #include "apr_errno.h"
   #include "apr_lib.h"
   #include "apr_thread_mutex.h"
  +#include "apr_poll.h"
   
   /* System headers the file I/O library needs */
   #if APR_HAVE_FCNTL_H
  @@ -130,6 +131,9 @@
       int buffered;
       enum {BLK_UNKNOWN, BLK_OFF, BLK_ON } blocking;
       int ungetchar;    /* Last char provided by an unget op. (-1 = no char)*/
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   
       /* Stuff for buffered mode */
       char *buffer;
  
  
  
  1.6       +4 -0      apr/include/arch/unix/apr_arch_networkio.h
  
  Index: apr_arch_networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/unix/apr_arch_networkio.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apr_arch_networkio.h	2 Nov 2003 20:51:18 -0000	1.5
  +++ apr_arch_networkio.h	17 Nov 2003 01:41:17 -0000	1.6
  @@ -61,6 +61,7 @@
   #include "apr_errno.h"
   #include "apr_general.h"
   #include "apr_lib.h"
  +#include "apr_poll.h"
   
   /* System headers the network I/O library needs */
   #if APR_HAVE_SYS_TYPES_H
  @@ -152,6 +153,9 @@
       apr_int32_t options;
       apr_int32_t inherit;
       sock_userdata_t *userdata;
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   };
   
   const char *apr_inet_ntop(int af, const void *src, char *dst, apr_size_t size);
  
  
  
  1.4       +4 -0      apr/include/arch/win32/apr_arch_file_io.h
  
  Index: apr_arch_file_io.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/apr_arch_file_io.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_arch_file_io.h	7 Jul 2003 22:44:11 -0000	1.3
  +++ apr_arch_file_io.h	17 Nov 2003 01:41:18 -0000	1.4
  @@ -65,6 +65,7 @@
   #include "apr_file_info.h"
   #include "apr_errno.h"
   #include "apr_arch_misc.h"
  +#include "apr_poll.h"
   
   #ifdef HAVE_SYS_STAT_H
   #include <sys/stat.h>
  @@ -214,6 +215,9 @@
       int direction;             // buffer being used for 0 = read, 1 = write
       apr_off_t filePtr;         // position in file of handle
       apr_thread_mutex_t *mutex; // mutex semaphore, must be owned to access the above fields
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   
       /* Pipe specific info */    
   };
  
  
  
  1.5       +4 -0      apr/include/arch/win32/apr_arch_networkio.h
  
  Index: apr_arch_networkio.h
  ===================================================================
  RCS file: /home/cvs/apr/include/arch/win32/apr_arch_networkio.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- apr_arch_networkio.h	4 Nov 2003 01:36:59 -0000	1.4
  +++ apr_arch_networkio.h	17 Nov 2003 01:41:18 -0000	1.5
  @@ -57,6 +57,7 @@
   
   #include "apr_network_io.h"
   #include "apr_general.h"
  +#include "apr_poll.h"
   
   typedef struct sock_userdata_t sock_userdata_t;
   struct sock_userdata_t {
  @@ -81,6 +82,9 @@
       apr_int32_t         options;
       apr_int32_t         inherit;
       sock_userdata_t    *userdata;
  +
  +    /* if there is a timeout set, then this pollset is used */
  +    apr_pollset_t *pollset;
   };
   
   #ifdef _WIN32_WCE
  
  
  
  1.31      +5 -5      apr/network_io/beos/sendrecv.c
  
  Index: sendrecv.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/beos/sendrecv.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- sendrecv.c	3 Sep 2003 16:31:47 -0000	1.30
  +++ sendrecv.c	17 Nov 2003 01:41:18 -0000	1.31
  @@ -59,7 +59,7 @@
   #include "apr_arch_networkio.h"
   #include "apr_time.h"
   
  -apr_status_t apr_wait_for_io_or_timeout(apr_socket_t *sock, int for_read)
  +static apr_status_t wait_for_io_or_timeout(apr_socket_t *sock, int for_read)
   {
       struct timeval tv, *tvptr;
       fd_set fdset;
  @@ -139,7 +139,7 @@
       } while (rv == -1 && errno == EINTR);
   
       if (rv == -1 && errno == EWOULDBLOCK && sock->timeout > 0) {
  -        apr_status_t arv = apr_wait_for_io_or_timeout(sock, 1);
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 1);
           if (arv != APR_SUCCESS) {
               *len = 0;
               return arv;
  @@ -185,7 +185,7 @@
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)
           && sock->timeout != 0) {
  -        apr_status_t arv = apr_wait_for_io_or_timeout(sock, 0);
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 0);
           if (arv != APR_SUCCESS) {
               *len = 0;
               return arv;
  @@ -226,7 +226,7 @@
   
       if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) &&
           sock->timeout != 0) {
  -        apr_status_t arv = apr_wait_for_io_or_timeout(sock, 1);
  +        apr_status_t arv = wait_for_io_or_timeout(sock, 1);
           if (arv != APR_SUCCESS) {
               *len = 0;
               return arv;
  @@ -249,4 +249,4 @@
       return APR_SUCCESS;
   }
   
  -#endif
  +#endif /* ! BEOS_BONE */
  
  
  
  1.67      +6 -0      apr/network_io/os2/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/os2/sockets.c,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- sockets.c	15 Oct 2003 20:41:44 -0000	1.66
  +++ sockets.c	17 Nov 2003 01:41:18 -0000	1.67
  @@ -103,6 +103,10 @@
       (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt,
                                                           sizeof(apr_sockaddr_t));
       (*new)->remote_addr->pool = p;
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, p, 0);
   }
   
   APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock, int *protocol)
  @@ -115,6 +119,7 @@
                                               int protocol, apr_pool_t *cont)
   {
       int downgrade = (family == AF_UNSPEC);
  +    apr_pollfd_t pfd;
   
       if (family == AF_UNSPEC) {
   #if APR_HAVE_IPV6
  @@ -143,6 +148,7 @@
       (*new)->nonblock = FALSE;
       apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), 
                           socket_cleanup, apr_pool_cleanup_null);
  +
       return APR_SUCCESS;
   } 
   
  
  
  
  1.114     +5 -0      apr/network_io/unix/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/unix/sockets.c,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- sockets.c	2 Nov 2003 20:51:18 -0000	1.113
  +++ sockets.c	17 Nov 2003 01:41:18 -0000	1.114
  @@ -103,6 +103,10 @@
       (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt,
                                                           sizeof(apr_sockaddr_t));
       (*new)->remote_addr->pool = p;
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, p, 0);
   }
   
   apr_status_t apr_socket_protocol_get(apr_socket_t *sock, int *protocol)
  @@ -144,6 +148,7 @@
       (*new)->inherit = 0;
       apr_pool_cleanup_register((*new)->cntxt, (void *)(*new), socket_cleanup,
                                 socket_cleanup);
  +
       return APR_SUCCESS;
   } 
   
  
  
  
  1.101     +4 -0      apr/network_io/win32/sockets.c
  
  Index: sockets.c
  ===================================================================
  RCS file: /home/cvs/apr/network_io/win32/sockets.c,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- sockets.c	2 Nov 2003 20:51:18 -0000	1.100
  +++ sockets.c	17 Nov 2003 01:41:18 -0000	1.101
  @@ -94,6 +94,10 @@
       (*new)->remote_addr = (apr_sockaddr_t *)apr_pcalloc((*new)->cntxt,
                                                           sizeof(apr_sockaddr_t));
       (*new)->remote_addr->pool = p;
  +
  +    /* Create a pollset with room for one descriptor. */
  +    /* ### check return codes */
  +    (void) apr_pollset_create(&(*new)->pollset, 1, cont, 0);
   }
   
   APR_DECLARE(apr_status_t) apr_socket_protocol_get(apr_socket_t *sock,
  
  
  
  1.7       +31 -15    apr/support/unix/waitio.c
  
  Index: waitio.c
  ===================================================================
  RCS file: /home/cvs/apr/support/unix/waitio.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- waitio.c	7 Jan 2003 00:52:56 -0000	1.6
  +++ waitio.c	17 Nov 2003 01:41:18 -0000	1.7
  @@ -65,38 +65,54 @@
   #endif
   
   #ifdef USE_WAIT_FOR_IO
  +
   apr_status_t apr_wait_for_io_or_timeout(apr_file_t *f, apr_socket_t *s,
  -                                           int for_read)
  +                                        int for_read)
   {
       apr_interval_time_t timeout;
  -    apr_pollfd_t pollset;
  -    int srv, n;
  +    apr_pollfd_t pfd;
       int type = for_read ? APR_POLLIN : APR_POLLOUT;
  +    apr_pollset_t *pollset;
  +    apr_status_t status;
   
       /* TODO - timeout should be less each time through this loop */
       if (f) {
  -        pollset.desc_type = APR_POLL_FILE;
  -        pollset.desc.f = f;
  -        pollset.p = f->pool;
  +        pfd.desc_type = APR_POLL_FILE;
  +        pfd.desc.f = f;
  +
  +        pollset = f->pollset;
           timeout = f->timeout;
       }
       else {
  -        pollset.desc_type = APR_POLL_SOCKET;
  -        pollset.desc.s = s;
  -        pollset.p = s->cntxt;
  +        pfd.desc_type = APR_POLL_SOCKET;
  +        pfd.desc.s = s;
  +
  +        pollset = s->pollset;
           timeout = s->timeout;
       }
  -    pollset.reqevents = type;
  +    pfd.reqevents = type;
  +
  +    /* Remove the object if it was in the pollset, then add in the new
  +     * object with the correct reqevents value. Ignore the status result
  +     * on the remove, because it might not be in there (yet).
  +     */
  +    (void) apr_pollset_remove(pollset, &pfd);
  +
  +    /* ### check status code */
  +    (void) apr_pollset_add(pollset, &pfd);
   
       do {
  -        srv = apr_poll(&pollset, 1, &n, timeout);
  +        int numdesc;
  +        const apr_pollfd_t *pdesc;
  +
  +        status = apr_pollset_poll(pollset, timeout, &numdesc, &pdesc);
   
  -        if (n == 1 && pollset.rtnevents & type) {
  +        if (numdesc == 1 && (pdesc[0].rtnevents & type) != 0) {
               return APR_SUCCESS;
           }
  -    } while (APR_STATUS_IS_EINTR(srv));
  +    } while (APR_STATUS_IS_EINTR(status));
   
  -    return srv;
  +    return status;
   }
  -#endif
   
  +#endif /* USE_WAIT_FOR_IO */
  
  
  

Re: cvs commit: apr/support/unix waitio.c

Posted by Jeff Trawick <tr...@attglobal.net>.
gstein@apache.org wrote:

> gstein      2003/11/16 17:41:18
> 
>   Log:
>   With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
>   needed to be rebuilt. Specifically, it needs a pollset, but we don't want
>   to allocate that all the time. Thus, we need to create it once at socket
>   or file creation time, and then reuse that pollset.

or, as was argued about long ago, just call poll() or select() directly in 
wait-for-io-or-timeout

obviously a compromise has to be made, with understandable arguments on either side



Re: cvs commit: apr/support/unix waitio.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On Tue, 18 Nov 2003 18:07:36 -0800, Greg Stein wrote:

>On Tue, Nov 18, 2003 at 07:50:20PM -0500, Jeff Trawick wrote:
>> Brian Havard wrote:
>> 
>> >> Log:
>> >> With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
>> >> needed to be rebuilt. Specifically, it needs a pollset, but we don't want
>> >> to allocate that all the time. Thus, we need to create it once at socket
>> >> or file creation time, and then reuse that pollset.
>> > 
>> > 
>> > You can't poll a file handle on OS/2 (APR_FILES_AS_SOCKETS == 0) so there's
>> > not really much point in having a pollset in the OS/2 apr_file_t, unless
>> > there's some grand scheme you're cooking up that I'm unaware of :)
>> > 
>> > Should I go ahead & clean them out?
>
>Yup, please. I had looked for users of the old API within httpd, but
>totally forgot to look within APR itself. Thus, I had to do a run-and-gun
>change to get everything fixed up. Mostly pattern-based fixes without a
>whole lot of thought/investigation of each specific object.

Ok, done that. Now waitio.c is broken as it's assuming a pollset member of
apr_file_t. Would you agree that this is appropriate?

Index: waitio.c
===================================================================
RCS file: /home/cvs/apr/support/unix/waitio.c,v
retrieving revision 1.7
diff -u -r1.7 waitio.c
--- waitio.c	17 Nov 2003 01:41:18 -0000	1.7
+++ waitio.c	19 Nov 2003 08:59:11 -0000
@@ -77,11 +77,15 @@
 
     /* TODO - timeout should be less each time through this loop */
     if (f) {
+#if APR_FILES_AS_SOCKETS
         pfd.desc_type = APR_POLL_FILE;
         pfd.desc.f = f;
 
         pollset = f->pollset;
         timeout = f->timeout;
+#else
+        return APR_ENOTIMPL;
+#endif
     }
     else {
         pfd.desc_type = APR_POLL_SOCKET;

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------


Re: cvs commit: apr/support/unix waitio.c

Posted by Greg Stein <gs...@lyra.org>.
On Tue, Nov 18, 2003 at 07:50:20PM -0500, Jeff Trawick wrote:
> Brian Havard wrote:
> 
> >> Log:
> >> With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
> >> needed to be rebuilt. Specifically, it needs a pollset, but we don't want
> >> to allocate that all the time. Thus, we need to create it once at socket
> >> or file creation time, and then reuse that pollset.
> > 
> > 
> > You can't poll a file handle on OS/2 (APR_FILES_AS_SOCKETS == 0) so there's
> > not really much point in having a pollset in the OS/2 apr_file_t, unless
> > there's some grand scheme you're cooking up that I'm unaware of :)
> > 
> > Should I go ahead & clean them out?

Yup, please. I had looked for users of the old API within httpd, but
totally forgot to look within APR itself. Thus, I had to do a run-and-gun
change to get everything fixed up. Mostly pattern-based fixes without a
whole lot of thought/investigation of each specific object.

> You can go ahead and clean it out of Unix side too for all I care, and I'll get 
> wait_for_io_or_timeout() to work again without the complications of managing 
> pollsets that we may never use.

One of the reasons we used apr_poll() was to avoid the #if logic in this
function. If you'd like to replicate that behavior into this function,
then go ahead. I didn't want to do it, though.

Another option that you can choose is to lazy-create the pollset. Use the
pool stored in the file/socket object.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/

Re: cvs commit: apr/support/unix waitio.c

Posted by Jeff Trawick <tr...@attglobal.net>.
Brian Havard wrote:

>> Log:
>> With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
>> needed to be rebuilt. Specifically, it needs a pollset, but we don't want
>> to allocate that all the time. Thus, we need to create it once at socket
>> or file creation time, and then reuse that pollset.
> 
> 
> You can't poll a file handle on OS/2 (APR_FILES_AS_SOCKETS == 0) so there's
> not really much point in having a pollset in the OS/2 apr_file_t, unless
> there's some grand scheme you're cooking up that I'm unaware of :)
> 
> Should I go ahead & clean them out?

You can go ahead and clean it out of Unix side too for all I care, and I'll get 
wait_for_io_or_timeout() to work again without the complications of managing 
pollsets that we may never use.



Re: cvs commit: apr/support/unix waitio.c

Posted by Brian Havard <br...@kheldar.apana.org.au>.
On 17 Nov 2003 01:41:18 -0000, gstein@apache.org wrote:

>gstein      2003/11/16 17:41:18
>
>  Modified:    file_io/os2 filedup.c open.c pipe.c
>               file_io/unix filedup.c open.c pipe.c
>               file_io/win32 filedup.c open.c pipe.c
>               include  apr_support.h
>               include/arch/netware apr_arch_file_io.h
>               include/arch/os2 apr_arch_file_io.h apr_arch_networkio.h
>               include/arch/unix apr_arch_file_io.h apr_arch_networkio.h
>               include/arch/win32 apr_arch_file_io.h apr_arch_networkio.h
>               network_io/beos sendrecv.c
>               network_io/os2 sockets.c
>               network_io/unix sockets.c
>               network_io/win32 sockets.c
>               support/unix waitio.c
>  Log:
>  With the removal of apr_poll(), the apr_wait_for_io_or_timeout() function
>  needed to be rebuilt. Specifically, it needs a pollset, but we don't want
>  to allocate that all the time. Thus, we need to create it once at socket
>  or file creation time, and then reuse that pollset.

You can't poll a file handle on OS/2 (APR_FILES_AS_SOCKETS == 0) so there's
not really much point in having a pollset in the OS/2 apr_file_t, unless
there's some grand scheme you're cooking up that I'm unaware of :)

Should I go ahead & clean them out?

-- 
 ______________________________________________________________________________
 |  Brian Havard                 |  "He is not the messiah!                   |
 |  brianh@kheldar.apana.org.au  |  He's a very naughty boy!" - Life of Brian |
 ------------------------------------------------------------------------------