You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by iv...@apache.org on 2017/08/30 15:23:42 UTC

svn commit: r1806701 - /apr/apr/trunk/file_io/win32/readwrite.c

Author: ivan
Date: Wed Aug 30 15:23:41 2017
New Revision: 1806701

URL: http://svn.apache.org/viewvc?rev=1806701&view=rev
Log:
Revert r1806592 and r1806603 that were meant to be a refactoring of the
Win32 file write code, but inadvertently changed the observed behavior.

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=1806701&r1=1806700&r2=1806701&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/readwrite.c (original)
+++ apr/apr/trunk/file_io/win32/readwrite.c Wed Aug 30 15:23:41 2017
@@ -409,24 +409,24 @@ APR_DECLARE(apr_status_t) apr_file_write
             rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote, &ov);
         }
         else {
+            apr_off_t offset = 0;
+            apr_status_t rc;
             if (thefile->append) {
-                apr_off_t offset = 0;
-
                 /* apr_file_lock will mutex the file across processes.
                  * The call to apr_thread_mutex_lock is added to avoid
                  * a race condition between LockFile and WriteFile 
                  * that occasionally leads to deadlocked threads.
                  */
                 apr_thread_mutex_lock(thefile->mutex);
-                rv = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE);
-                if (rv != APR_SUCCESS) {
+                rc = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE);
+                if (rc != APR_SUCCESS) {
                     apr_thread_mutex_unlock(thefile->mutex);
-                    return rv;
+                    return rc;
                 }
-                rv = apr_file_seek(thefile, APR_END, &offset);
-                if (rv != APR_SUCCESS) {
+                rc = apr_file_seek(thefile, APR_END, &offset);
+                if (rc != APR_SUCCESS) {
                     apr_thread_mutex_unlock(thefile->mutex);
-                    return rv;
+                    return rc;
                 }
             }
             if (thefile->pOverlapped) {
@@ -435,9 +435,6 @@ APR_DECLARE(apr_status_t) apr_file_write
             }
             rv = WriteFile(thefile->filehand, buf, (DWORD)*nbytes, &bwrote,
                            thefile->pOverlapped);
-            if (rv == APR_SUCCESS && thefile->pOverlapped) {
-                thefile->filePtr += *nbytes;
-            }
             if (thefile->append) {
                 apr_file_unlock(thefile);
                 apr_thread_mutex_unlock(thefile->mutex);
@@ -489,6 +486,9 @@ APR_DECLARE(apr_status_t) apr_file_write
                 }
             }
         }
+        if (rv == APR_SUCCESS && thefile->pOverlapped && !thefile->pipe) {
+            thefile->filePtr += *nbytes;
+        }
     }
     return rv;
 }