You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bj...@apache.org on 2010/04/04 18:50:09 UTC

svn commit: r930716 - /apr/apr/trunk/file_io/os2/seek.c

Author: bjh
Date: Sun Apr  4 16:50:08 2010
New Revision: 930716

URL: http://svn.apache.org/viewvc?rev=930716&view=rev
Log:
OS/2: Add missing locking in apr_file_seek() for buffered files.

Modified:
    apr/apr/trunk/file_io/os2/seek.c

Modified: apr/apr/trunk/file_io/os2/seek.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/os2/seek.c?rev=930716&r1=930715&r2=930716&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/seek.c (original)
+++ apr/apr/trunk/file_io/os2/seek.c Sun Apr  4 16:50:08 2010
@@ -27,7 +27,6 @@ static apr_status_t setptr(apr_file_t *t
     ULONG rc;
 
     if (thefile->direction == 1) {
-        /* XXX: flush here is not mutex protected */
         apr_status_t rv = apr_file_flush(thefile);
 
         if (rv != APR_SUCCESS) {
@@ -65,6 +64,10 @@ APR_DECLARE(apr_status_t) apr_file_seek(
         int rc = EINVAL;
         apr_finfo_t finfo;
 
+        if (thefile->mutex) {
+            apr_thread_mutex_lock(thefile->mutex);
+        }
+
         switch (where) {
         case APR_SET:
             rc = setptr(thefile, *offset);
@@ -82,6 +85,11 @@ APR_DECLARE(apr_status_t) apr_file_seek(
         }
 
         *offset = thefile->filePtr - thefile->dataRead + thefile->bufpos;
+
+        if (thefile->mutex) {
+            apr_thread_mutex_unlock(thefile->mutex);
+        }
+
         return rc;
     } else {
         switch (where) {