apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject svn commit: r1806592 - /apr/apr/trunk/file_io/win32/readwrite.c
Date Tue, 29 Aug 2017 13:49:03 GMT
Author: ivan
Date: Tue Aug 29 13:49:03 2017
New Revision: 1806592

URL: http://svn.apache.org/viewvc?rev=1806592&view=rev
Log:
Minor refactoring of the Win32 file write code.

* file_io/win32/readwrite.c
  (apr_file_write): Reuse the existing 'rv' variable to store the
   status code.  Reduce the scope of the 'offset' variable.

Patch by: Evgeny Kotkov <evgeny.kotkov {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=1806592&r1=1806591&r2=1806592&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/readwrite.c (original)
+++ apr/apr/trunk/file_io/win32/readwrite.c Tue Aug 29 13:49:03 2017
@@ -372,24 +372,24 @@ APR_DECLARE(apr_status_t) apr_file_write
         return rv;
     } else {
         if (!thefile->pipe) {
-            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);
-                rc = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE);
-                if (rc != APR_SUCCESS) {
+                rv = apr_file_lock(thefile, APR_FLOCK_EXCLUSIVE);
+                if (rv != APR_SUCCESS) {
                     apr_thread_mutex_unlock(thefile->mutex);
-                    return rc;
+                    return rv;
                 }
-                rc = apr_file_seek(thefile, APR_END, &offset);
-                if (rc != APR_SUCCESS) {
+                rv = apr_file_seek(thefile, APR_END, &offset);
+                if (rv != APR_SUCCESS) {
                     apr_thread_mutex_unlock(thefile->mutex);
-                    return rc;
+                    return rv;
                 }
             }
             if (thefile->pOverlapped) {



Mime
View raw message