diff options
author | Ivan Zhakov <ivan@apache.org> | 2017-08-30 15:23:41 +0000 |
---|---|---|
committer | Ivan Zhakov <ivan@apache.org> | 2017-08-30 15:23:41 +0000 |
commit | 554f3a7f0f681ace62df115155a4dd73555e5981 (patch) | |
tree | 0b53f3ec7e13db52af0ff07e23822821c5cf97f1 /file_io | |
parent | 2aacbfc252757b1923c85ff9ce5f27bcffdda152 (diff) | |
download | apr-554f3a7f0f681ace62df115155a4dd73555e5981.tar.gz |
Revert r1806592 and r1806603 that were meant to be a refactoring of the
Win32 file write code, but inadvertently changed the observed behavior.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1806701 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'file_io')
-rw-r--r-- | file_io/win32/readwrite.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/file_io/win32/readwrite.c b/file_io/win32/readwrite.c index 8aec4c80f..e2e3e10ca 100644 --- a/file_io/win32/readwrite.c +++ b/file_io/win32/readwrite.c @@ -409,24 +409,24 @@ APR_DECLARE(apr_status_t) apr_file_write(apr_file_t *thefile, const void *buf, a 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(apr_file_t *thefile, const void *buf, a } 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(apr_file_t *thefile, const void *buf, a } } } + if (rv == APR_SUCCESS && thefile->pOverlapped && !thefile->pipe) { + thefile->filePtr += *nbytes; + } } return rv; } |