On 10/15/2011 4:10 PM, [email protected] wrote:
Author: sf
Date: Sat Oct 15 21:10:18 2011
New Revision: 1183715

URL: http://svn.apache.org/viewvc?rev=1183715&view=rev
Log:
Backport r1183688:

     Fix race condition that could lead to EEXIST being returned

     PR: 51254
     Submitted by: William Lee<william lee rainstor com>,
                   Wim Lewis<wiml omnigroup com>
[...]
Modified: apr/apr/branches/1.4.x/file_io/win32/dir.c
URL: 
http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/file_io/win32/dir.c?rev=1183715&r1=1183714&r2=1183715&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/file_io/win32/dir.c (original)
+++ apr/apr/branches/1.4.x/file_io/win32/dir.c Sat Oct 15 21:10:18 2011
@@ -333,9 +333,6 @@ APR_DECLARE(apr_status_t) apr_dir_make_r

      rv = apr_dir_make (path, perm, pool); /* Try to make PATH right out */

-    if (APR_STATUS_IS_EEXIST(rv)) /* It's OK if PATH exists */
-        return APR_SUCCESS;
-
      if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */
          char *dir;

@@ -347,6 +344,15 @@ APR_DECLARE(apr_status_t) apr_dir_make_r
          if (rv == APR_SUCCESS)
              rv = apr_dir_make (dir, perm, pool);   /* And complete the path */
      }
+
+    /*
+     * It's OK if PATH exists. Timing issues can lead to the second
+     * apr_dir_make being called on existing dir, therefore this check
+     * has to come last.
+     */
+    if (APR_STATUS_IS_EEXIST(apr_err))
+        return APR_SUCCESS;
+
      return rv;
  }


Stefan, what is an apr_err?  Inquiring compilers want to know.  Pls fix.

Reply via email to