You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dg...@locus.apache.org on 2000/04/11 18:28:38 UTC

cvs commit: apache-2.0/src/include ap_iol.h buff.h

dgaudet     00/04/11 09:28:38

  Modified:    src/include ap_iol.h buff.h
  Log:
  i think timeouts should be in microseconds...
  
  Revision  Changes    Path
  1.15      +2 -0      apache-2.0/src/include/ap_iol.h
  
  Index: ap_iol.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/ap_iol.h,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ap_iol.h	2000/03/31 07:18:51	1.14
  +++ ap_iol.h	2000/04/11 16:28:37	1.15
  @@ -82,6 +82,8 @@
       of seconds.  If the read/write can't be completed in that time,
       APR_ETIMEDOUT will be returned.
   
  +    XXX: timeouts should probably be redefined to be in microseconds to match APR.
  +
       Just to drive the point home again -- none of these functions guarantee
       they will read/write the entire length specified.
   
  
  
  
  1.16      +1 -0      apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- buff.h	2000/03/31 07:18:55	1.15
  +++ buff.h	2000/04/11 16:28:38	1.16
  @@ -160,6 +160,7 @@
   
   /* Options to bset/getopt */
   #define BO_BYTECT (1)
  +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
   /* timeout values have the same semantics as those documented for timeouts
      in ap_iol.h... that is:
      timeout < 0 is blocking infinite/no-timeout
  
  
  

Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> > Which part of APR do you want to match?  The timeout parameters for
> > ap_poll() and ap_set_pipe_timeout() are in seconds.
> 
> Those have just never been redefined to use ap_time_t's.  This code and
> APR's code should all use ap_time_t's now.
> 
> Ryan

Thanks!

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> > > >    /* Options to bset/getopt */
> > > >    #define BO_BYTECT (1)
> > > >   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
> > > >    /* timeout values have the same semantics as those documented for timeouts
> > > >       in ap_iol.h... that is:
> > > >       timeout < 0 is blocking infinite/no-timeout
> > > 
> > > Which part of APR do you want to match?  The timeout parameters for
> > > ap_poll() and ap_set_pipe_timeout() are in seconds.
> > 
> > Those have just never been redefined to use ap_time_t's.  This code and
> > APR's code should all use ap_time_t's now.
> 
> yeah, that's sort of what i meant...  strictly speaking we should define
> another type ap_interval_time_t, because ap_time_t is defined to be
> absolute... and interval timers can actually be 32-bits (limits us to
> 35 minute timeouts, no biggie in my books).  but comparing interval
> timers is a bit tricky, once again i refer to NSPR 'cause i'm too lazy
> to explain it right now :)
> 
> but i won't complain much if folks just want to abuse ap_time_t for now.
> 
> -dean

Here's a baby step that supposedly implements what you're talking about...

Remaining baby steps in APR...  

  same crap for poll and socket timeouts (win32 has only millisecond
  resolution but so what)

Then...
  use microseconds in Apache instead of converting to microseconds at
  the APR boundary

Index: lib/apr/file_io/os2/pipe.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/pipe.c,v
retrieving revision 1.13
diff -u -r1.13 pipe.c
--- lib/apr/file_io/os2/pipe.c	2000/04/08 06:58:39	1.13
+++ lib/apr/file_io/os2/pipe.c	2000/04/14 14:31:48
@@ -100,7 +100,7 @@
 
  
 
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout)
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout)
 {
     return APR_ENOTIMPL;
 }
Index: lib/apr/file_io/unix/fileio.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/fileio.h,v
retrieving revision 1.15
diff -u -r1.15 fileio.h
--- lib/apr/file_io/unix/fileio.h	2000/04/14 00:58:38	1.15
+++ lib/apr/file_io/unix/fileio.h	2000/04/14 14:31:48
@@ -107,7 +107,7 @@
     int oflags;
     int eof_hit;
     int pipe;
-    int timeout;
+    ap_interval_time_t timeout;
     int ungetchar;    /* Last char provided by an unget op. (-1 = no char)*/
 };
 
Index: lib/apr/file_io/unix/pipe.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/pipe.c,v
retrieving revision 1.24
diff -u -r1.24 pipe.c
--- lib/apr/file_io/unix/pipe.c	2000/04/14 00:58:38	1.24
+++ lib/apr/file_io/unix/pipe.c	2000/04/14 14:31:48
@@ -76,8 +76,7 @@
     return APR_SUCCESS;
 }
 
-
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout)
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout)
 {
     if(thepipe == NULL)
         return APR_EBADARG;
Index: lib/apr/file_io/unix/readwrite.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/unix/readwrite.c,v
retrieving revision 1.39
diff -u -r1.39 readwrite.c
--- lib/apr/file_io/unix/readwrite.c	2000/04/14 00:46:49	1.39
+++ lib/apr/file_io/unix/readwrite.c	2000/04/14 14:31:48
@@ -56,20 +56,26 @@
 
 static ap_status_t wait_for_io_or_timeout(ap_file_t *file, int for_read)
 {
-    struct timeval tv;
+    struct timeval tv, *tvptr;
     fd_set fdset;
     int srv;
 
     do {
         FD_ZERO(&fdset);
         FD_SET(file->filedes, &fdset);
-        tv.tv_sec = file->timeout;
-        tv.tv_usec = 0;
+        if (file->timeout >= 0) {
+            tv.tv_sec = file->timeout / AP_USEC_PER_SEC;
+            tv.tv_usec = file->timeout % AP_USEC_PER_SEC;
+            tvptr = &tv;
+        }
+        else {
+            tvptr = NULL;
+        }
         srv = select(FD_SETSIZE,
             for_read ? &fdset : NULL,
             for_read ? NULL : &fdset,
             NULL,
-            file->timeout < 0 ? NULL : &tv);
+            tvptr);
     } while (srv == -1 && errno == EINTR);
 
     if (srv == 0) {
Index: lib/apr/file_io/win32/fileio.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/fileio.h,v
retrieving revision 1.15
diff -u -r1.15 fileio.h
--- lib/apr/file_io/win32/fileio.h	2000/04/12 22:10:16	1.15
+++ lib/apr/file_io/win32/fileio.h	2000/04/14 14:31:48
@@ -110,7 +110,7 @@
     ap_time_t mtime;
     ap_time_t ctime;
     int pipe;
-    int timeout;
+    ap_interval_time_t timeout;
 };
 
 struct ap_dir_t {
Index: lib/apr/include/apr_file_io.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
retrieving revision 1.41
diff -u -r1.41 apr_file_io.h
--- lib/apr/include/apr_file_io.h	2000/04/14 00:55:02	1.41
+++ lib/apr/include/apr_file_io.h	2000/04/14 14:31:48
@@ -421,7 +421,7 @@
  * arg 3) The timeout value in seconds.  Values < 0 mean wait forever, 0
  *        means do not wait at all.
  */
-ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_int32_t timeout);
+ap_status_t ap_set_pipe_timeout(ap_file_t *thepipe, ap_interval_time_t timeout);
 
 /* ***APRDOC********************************************************
  * ap_status_t ap_block_pipe(ap_file_t *thepipe)
Index: lib/apr/include/apr_time.h
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_time.h,v
retrieving revision 1.16
diff -u -r1.16 apr_time.h
--- lib/apr/include/apr_time.h	2000/04/14 01:38:41	1.16
+++ lib/apr/include/apr_time.h	2000/04/14 14:31:48
@@ -68,6 +68,9 @@
 /* number of microseconds since 00:00:00 january 1, 1970 UTC */
 typedef ap_int64_t ap_time_t;
 
+/* intervals for I/O timeouts, in microseconds */
+typedef ap_int32_t ap_interval_time_t;
+
 #ifdef WIN32
 #define AP_USEC_PER_SEC ((LONGLONG) 1000000)
 #else
Index: lib/apr/test/testpipe.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/lib/apr/test/testpipe.c,v
retrieving revision 1.5
diff -u -r1.5 testpipe.c
--- lib/apr/test/testpipe.c	2000/04/14 13:42:09	1.5
+++ lib/apr/test/testpipe.c	2000/04/14 14:31:51
@@ -95,7 +95,7 @@
     }
     
     fprintf(stdout, "\tSetting pipe timeout.......");
-    if (ap_set_pipe_timeout(readp, 1) != APR_SUCCESS) {
+    if (ap_set_pipe_timeout(readp, 1 * AP_USEC_PER_SEC) != APR_SUCCESS) {
         perror("Couldn't set a timeout");
         exit(-1);
     } else {
Index: main/iol_file.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/main/iol_file.c,v
retrieving revision 1.13
diff -u -r1.13 iol_file.c
--- main/iol_file.c	2000/04/06 01:46:08	1.13
+++ main/iol_file.c	2000/04/14 14:31:54
@@ -125,7 +125,8 @@
 
     switch (opt) {
     case AP_IOL_TIMEOUT:
-        return ap_set_pipe_timeout(iol->file, *(const int*)value);
+        return ap_set_pipe_timeout(iol->file, 
+				   *(const int*)value * AP_USEC_PER_SEC);
     default:
         return APR_EINVAL;
     }



-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by dean gaudet <dg...@arctic.org>.
On Thu, 13 Apr 2000 rbb@covalent.net wrote:

> 
> > >    /* Options to bset/getopt */
> > >    #define BO_BYTECT (1)
> > >   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
> > >    /* timeout values have the same semantics as those documented for timeouts
> > >       in ap_iol.h... that is:
> > >       timeout < 0 is blocking infinite/no-timeout
> > 
> > Which part of APR do you want to match?  The timeout parameters for
> > ap_poll() and ap_set_pipe_timeout() are in seconds.
> 
> Those have just never been redefined to use ap_time_t's.  This code and
> APR's code should all use ap_time_t's now.

yeah, that's sort of what i meant...  strictly speaking we should define
another type ap_interval_time_t, because ap_time_t is defined to be
absolute... and interval timers can actually be 32-bits (limits us to
35 minute timeouts, no biggie in my books).  but comparing interval
timers is a bit tricky, once again i refer to NSPR 'cause i'm too lazy
to explain it right now :)

but i won't complain much if folks just want to abuse ap_time_t for now.

-dean


Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by rb...@covalent.net.
> >    /* Options to bset/getopt */
> >    #define BO_BYTECT (1)
> >   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
> >    /* timeout values have the same semantics as those documented for timeouts
> >       in ap_iol.h... that is:
> >       timeout < 0 is blocking infinite/no-timeout
> 
> Which part of APR do you want to match?  The timeout parameters for
> ap_poll() and ap_set_pipe_timeout() are in seconds.

Those have just never been redefined to use ap_time_t's.  This code and
APR's code should all use ap_time_t's now.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by rb...@covalent.net.
> >    /* Options to bset/getopt */
> >    #define BO_BYTECT (1)
> >   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
> >    /* timeout values have the same semantics as those documented for timeouts
> >       in ap_iol.h... that is:
> >       timeout < 0 is blocking infinite/no-timeout
> 
> Which part of APR do you want to match?  The timeout parameters for
> ap_poll() and ap_set_pipe_timeout() are in seconds.

Those have just never been redefined to use ap_time_t's.  This code and
APR's code should all use ap_time_t's now.

Ryan

_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> dgaudet     00/04/11 09:28:38
> 
>   --- ap_iol.h	2000/03/31 07:18:51	1.14
>   +++ ap_iol.h	2000/04/11 16:28:37	1.15
>   @@ -82,6 +82,8 @@
>        of seconds.  If the read/write can't be completed in that time,
>        APR_ETIMEDOUT will be returned.
>    
>   +    XXX: timeouts should probably be redefined to be in microseconds to match APR.
>   +
>        Just to drive the point home again -- none of these functions guarantee
>        they will read/write the entire length specified.
>
>   --- buff.h	2000/03/31 07:18:55	1.15
>   +++ buff.h	2000/04/11 16:28:38	1.16
>   @@ -160,6 +160,7 @@
>    
>    /* Options to bset/getopt */
>    #define BO_BYTECT (1)
>   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
>    /* timeout values have the same semantics as those documented for timeouts
>       in ap_iol.h... that is:
>       timeout < 0 is blocking infinite/no-timeout

Which part of APR do you want to match?  The timeout parameters for
ap_poll() and ap_set_pipe_timeout() are in seconds.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...

Re: cvs commit: apache-2.0/src/include ap_iol.h buff.h

Posted by Jeff Trawick <tr...@bellsouth.net>.
> dgaudet     00/04/11 09:28:38
> 
>   --- ap_iol.h	2000/03/31 07:18:51	1.14
>   +++ ap_iol.h	2000/04/11 16:28:37	1.15
>   @@ -82,6 +82,8 @@
>        of seconds.  If the read/write can't be completed in that time,
>        APR_ETIMEDOUT will be returned.
>    
>   +    XXX: timeouts should probably be redefined to be in microseconds to match APR.
>   +
>        Just to drive the point home again -- none of these functions guarantee
>        they will read/write the entire length specified.
>
>   --- buff.h	2000/03/31 07:18:55	1.15
>   +++ buff.h	2000/04/11 16:28:38	1.16
>   @@ -160,6 +160,7 @@
>    
>    /* Options to bset/getopt */
>    #define BO_BYTECT (1)
>   +/* XXX: timeouts should probably be redefined to be in microseconds to match APR */
>    /* timeout values have the same semantics as those documented for timeouts
>       in ap_iol.h... that is:
>       timeout < 0 is blocking infinite/no-timeout

Which part of APR do you want to match?  The timeout parameters for
ap_poll() and ap_set_pipe_timeout() are in seconds.

-- 
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
     http://www.geocities.com/SiliconValley/Park/9289/
          Born in Roswell... married an alien...