You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2011/10/15 22:48:52 UTC
svn commit: r1183688 - in /apr/apr/trunk: CHANGES
file_io/os2/dir_make_recurse.c file_io/unix/dir.c file_io/win32/dir.c
Author: sf
Date: Sat Oct 15 20:48:52 2011
New Revision: 1183688
URL: http://svn.apache.org/viewvc?rev=1183688&view=rev
Log:
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/trunk/CHANGES
apr/apr/trunk/file_io/os2/dir_make_recurse.c
apr/apr/trunk/file_io/unix/dir.c
apr/apr/trunk/file_io/win32/dir.c
Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1183688&r1=1183687&r2=1183688&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Sat Oct 15 20:48:52 2011
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes for APR 2.0.0
+ *) apr_dir_make_recursive: Fix race condition that could lead to EEXIST
+ being returned. PR 51254. [William Lee <william lee rainstor com>,
+ Wim Lewis <wiml omnigroup com>]
+
*) configure: Fix APR_RESTORE_THE_ENVIRONMENT if the original variable was
a single space. PR 50334. [Nathan Phillip Brink <binki gentoo org>]
Modified: apr/apr/trunk/file_io/os2/dir_make_recurse.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/os2/dir_make_recurse.c?rev=1183688&r1=1183687&r2=1183688&view=diff
==============================================================================
--- apr/apr/trunk/file_io/os2/dir_make_recurse.c (original)
+++ apr/apr/trunk/file_io/os2/dir_make_recurse.c Sat Oct 15 20:48:52 2011
@@ -67,10 +67,6 @@ apr_status_t apr_dir_make_recursive(cons
apr_err = apr_dir_make(path, perm, pool); /* Try to make PATH right out */
- if (APR_STATUS_IS_EEXIST(apr_err)) { /* It's OK if PATH exists */
- return APR_SUCCESS;
- }
-
if (APR_STATUS_IS_ENOENT(apr_err)) { /* Missing an intermediate dir */
char *dir;
@@ -82,5 +78,13 @@ apr_status_t apr_dir_make_recursive(cons
}
}
+ /*
+ * 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 apr_err;
}
Modified: apr/apr/trunk/file_io/unix/dir.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/dir.c?rev=1183688&r1=1183687&r2=1183688&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/dir.c (original)
+++ apr/apr/trunk/file_io/unix/dir.c Sat Oct 15 20:48:52 2011
@@ -305,9 +305,6 @@ apr_status_t apr_dir_make_recursive(cons
apr_err = apr_dir_make (path, perm, pool); /* Try to make PATH right out */
- if (apr_err == EEXIST) /* It's OK if PATH exists */
- return APR_SUCCESS;
-
if (apr_err == ENOENT) { /* Missing an intermediate dir */
char *dir;
@@ -323,6 +320,14 @@ apr_status_t apr_dir_make_recursive(cons
apr_err = apr_dir_make (path, perm, pool);
}
+ /*
+ * 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 apr_err;
}
Modified: apr/apr/trunk/file_io/win32/dir.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/win32/dir.c?rev=1183688&r1=1183687&r2=1183688&view=diff
==============================================================================
--- apr/apr/trunk/file_io/win32/dir.c (original)
+++ apr/apr/trunk/file_io/win32/dir.c Sat Oct 15 20:48:52 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;
}