httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@locus.apache.org
Subject cvs commit: apache-2.0/src/lib/apr/file_io/os2 fileio.h open.c readwrite.c
Date Tue, 18 Apr 2000 14:53:29 GMT
bjh         00/04/18 07:53:29

  Modified:    src/lib/apr/file_io/os2 fileio.h open.c readwrite.c
  Log:
  OS/2: Switch from using critical sections to mutex semaphores for making
  the buffering code thread safe. It's the more subtle approach and is
  actually faster too.
  
  Revision  Changes    Path
  1.16      +2 -0      apache-2.0/src/lib/apr/file_io/os2/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/fileio.h,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- fileio.h	2000/04/14 15:58:21	1.15
  +++ fileio.h	2000/04/18 14:53:28	1.16
  @@ -60,6 +60,7 @@
   
   #include "apr_config.h"
   #include "apr_general.h"
  +#include "apr_lock.h"
   #include "apr_file_io.h"
   #include "apr_errno.h"
   
  @@ -80,6 +81,7 @@
       unsigned long dataRead;   // amount of valid data read into buffer
       int direction;            // buffer being used for 0 = read, 1 = write
       unsigned long filePtr;    // position in file of handle
  +    ap_lock_t *mutex;         // mutex semaphore, must be owned to access the above fields
   };
   
   struct ap_dir_t {
  
  
  
  1.22      +11 -3     apache-2.0/src/lib/apr/file_io/os2/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/open.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- open.c	2000/04/14 15:58:21	1.21
  +++ open.c	2000/04/18 14:53:29	1.22
  @@ -97,6 +97,14 @@
   
       dafile->buffered = (flag & APR_BUFFERED) > 0;
   
  +    if (dafile->buffered) {
  +        dafile->buffer = ap_palloc(cntxt, APR_FILE_BUFSIZE);
  +        rv = ap_create_lock(&dafile->mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, cntxt);
  +
  +        if (rv)
  +            return APR_OS2_STATUS(rv);
  +    }
  +
       if (flag & APR_CREATE) {
           oflags |= OPEN_ACTION_CREATE_IF_NEW; 
           if (!(flag & APR_EXCL)) {
  @@ -136,9 +144,6 @@
       dafile->dataRead = 0;
       dafile->direction = 0;
   
  -    if (dafile->buffered)
  -        dafile->buffer = ap_palloc(cntxt, APR_FILE_BUFSIZE);
  -
       ap_register_cleanup(dafile->cntxt, dafile, apr_file_cleanup, ap_null_cleanup);
       return APR_SUCCESS;
   }
  @@ -165,6 +170,9 @@
               return APR_OS2_STATUS(rc);
           }
       }
  +
  +    if (file->buffered)
  +        ap_destroy_lock(file->mutex);
   
       return APR_SUCCESS;
   }
  
  
  
  1.21      +5 -3      apache-2.0/src/lib/apr/file_io/os2/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/os2/readwrite.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- readwrite.c	2000/04/08 07:30:34	1.20
  +++ readwrite.c	2000/04/18 14:53:29	1.21
  @@ -52,11 +52,13 @@
    * <http://www.apache.org/>.
    */
   
  +#define INCL_DOS
  +#define INCL_DOSERRORS
  +
   #include "fileio.h"
   #include "apr_file_io.h"
   #include "apr_lib.h"
   
  -#define INCL_DOS
   #include <os2.h>
   #include <malloc.h>
   
  @@ -75,7 +77,7 @@
           ULONG blocksize;
           ULONG size = *nbytes;
   
  -        DosEnterCritSec();
  +        ap_lock(thefile->mutex);
   
           if (thefile->direction == 1) {
               ap_flush(thefile);
  @@ -104,7 +106,7 @@
           }
   
           *nbytes = rc == 0 ? pos - (char *)buf : 0;
  -        DosExitCritSec();
  +        ap_unlock(thefile->mutex);
           return APR_OS2_STATUS(rc);
       } else {
           rc = DosRead(thefile->filedes, buf, *nbytes, &bytesread);
  
  
  

Mime
View raw message