apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject svn commit: r960671 - /apr/apr/trunk/file_io/win32/readwrite.c
Date Mon, 05 Jul 2010 19:47:08 GMT
Author: gstein
Date: Mon Jul  5 19:47:08 2010
New Revision: 960671

URL: http://svn.apache.org/viewvc?rev=960671&view=rev
Log:
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

Patch By: Ivan Zhakov <ivan {at} visualsvn.com>

Modified:
    apr/apr/trunk/file_io/win32/readwrite.c

Modified: apr/apr/trunk/file_io/win32/readwrite.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/readwrite.c?rev=960671&r1=960670&r2=960671&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/readwrite.c (original)
+++ apr/apr/trunk/file_io/win32/readwrite.c Mon Jul  5 19:47:08 2010
@@ -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