diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-06-07 12:04:43 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2003-06-07 12:04:43 +0000 |
commit | 59957e9680ffe140dde6a7d301d250e659c6a109 (patch) | |
tree | ef6b19e2189129859c1dbc2336105e3c52f77da2 /locks | |
parent | a4516f9909dabd5e550b01969350e144ee51be10 (diff) | |
download | libapr-59957e9680ffe140dde6a7d301d250e659c6a109.tar.gz |
When using a temporary file for flock- and fcntl-based mutexes,
don't let the file be deleted on close. For flock-based mutexes,
this corrects a fatal problem, since the file would disappear
when a program was spawned and cleanup-for-exec was performed,
and a subsequent attempt to perform child process mutex
initialization would fail. For fcntl-based mutexes, this was a
very minor issue that resulted in a failing unlink() when the
file was closed, since fcntl lock initialization always removes
the file immediately.
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64529 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r-- | locks/unix/proc_mutex.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index 0a98e81f2..1ad35de4a 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -516,7 +516,8 @@ static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex, } else { new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, 0, + rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, + APR_CREATE | APR_WRITE | APR_EXCL, new_mutex->pool); } @@ -526,11 +527,6 @@ static apr_status_t proc_mutex_fcntl_create(apr_proc_mutex_t *new_mutex, } new_mutex->curr_locked = 0; - /* XXX currently, apr_file_mktemp() always specifies that the file should - * be removed when closed; that unlink() will fail since we're - * removing it here; we want to remove it here since we don't need - * it visible and we want it cleaned up if we exit catastrophically - */ unlink(new_mutex->fname); apr_pool_cleanup_register(new_mutex->pool, (void*)new_mutex, @@ -631,7 +627,8 @@ static apr_status_t proc_mutex_flock_create(apr_proc_mutex_t *new_mutex, } else { new_mutex->fname = apr_pstrdup(new_mutex->pool, "/tmp/aprXXXXXX"); - rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, 0, + rv = apr_file_mktemp(&new_mutex->interproc, new_mutex->fname, + APR_CREATE | APR_WRITE | APR_EXCL, new_mutex->pool); } |