apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1534139 - in /apr/apr/branches/1.5.x: ./ CHANGES file_io/win32/readwrite.c
Date Mon, 21 Oct 2013 12:57:05 GMT
Author: trawick
Date: Mon Oct 21 12:57:05 2013
New Revision: 1534139

URL: http://svn.apache.org/r1534139
Log:
Merge r960671 from trunk:

Only deal with the mutex when XTHREAD is enabled. This increases the
performance of buffered reads/writes tremendously.

* file_io/win32/readwrite.c:
  (apr_file_read, apr_file_write): only manipulate mutex when XTHREAD

Submitted by: Ivan Zhakov <ivan visualsvn.com>

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/CHANGES
    apr/apr/branches/1.5.x/file_io/win32/readwrite.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r960671

Modified: apr/apr/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CHANGES?rev=1534139&r1=1534138&r2=1534139&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.5.x/CHANGES [utf-8] Mon Oct 21 12:57:05 2013
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.5.0
 
+  *) Windows:  Don't obtain a mutex for buffered file I/O unless the
+     file was opened with the APR_FOPEN_XTHREAD flag.  [Ivan Zhakov
+     <ivan visualsvn.com>]
+
   *) Windows:  Create named shared memory segments under the "Local"
      namespace if the caller is unprivileged, fixing an inability of
      unprivileged callers to use apr_shm_create() with named shared

Modified: apr/apr/branches/1.5.x/file_io/win32/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/file_io/win32/readwrite.c?rev=1534139&r1=1534138&r2=1534139&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/file_io/win32/readwrite.c (original)
+++ apr/apr/branches/1.5.x/file_io/win32/readwrite.c Mon Oct 21 12:57:05 2013
@@ -181,12 +181,16 @@ APR_DECLARE(apr_status_t) apr_file_read(
         apr_size_t blocksize;
         apr_size_t size = *len;
 
-        apr_thread_mutex_lock(thefile->mutex);
+        if (thefile->flags & APR_FOPEN_XTHREAD) {
+            apr_thread_mutex_lock(thefile->mutex);
+        }
 
         if (thefile->direction == 1) {
             rv = apr_file_flush(thefile);
             if (rv != APR_SUCCESS) {
-                apr_thread_mutex_unlock(thefile->mutex);
+                if (thefile->flags & APR_FOPEN_XTHREAD) {
+                    apr_thread_mutex_unlock(thefile->mutex);
+                }
                 return rv;
             }
             thefile->bufpos = 0;
@@ -223,7 +227,10 @@ APR_DECLARE(apr_status_t) apr_file_read(
         if (*len) {
             rv = APR_SUCCESS;
         }
-        apr_thread_mutex_unlock(thefile->mutex);
+
+        if (thefile->flags & APR_FOPEN_XTHREAD) {
+            apr_thread_mutex_unlock(thefile->mutex);
+        }
     } else {  
         /* Unbuffered i/o */
         apr_size_t nbytes;
@@ -260,7 +267,9 @@ APR_DECLARE(apr_status_t) apr_file_write
         apr_size_t blocksize;
         apr_size_t size = *nbytes;
 
-        apr_thread_mutex_lock(thefile->mutex);
+        if (thefile->flags & APR_FOPEN_XTHREAD) {
+            apr_thread_mutex_lock(thefile->mutex);
+        }
 
         if (thefile->direction == 0) {
             /* Position file pointer for writing at the offset we are logically reading from
*/
@@ -286,7 +295,9 @@ APR_DECLARE(apr_status_t) apr_file_write
             size -= blocksize;
         }
 
-        apr_thread_mutex_unlock(thefile->mutex);
+        if (thefile->flags & APR_FOPEN_XTHREAD) {
+            apr_thread_mutex_unlock(thefile->mutex);
+        }
         return rv;
     } else {
         if (!thefile->pipe) {



Mime
View raw message