From 59957e9680ffe140dde6a7d301d250e659c6a109 Mon Sep 17 00:00:00 2001 From: trawick Date: Sat, 7 Jun 2003 12:04:43 +0000 Subject: 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 --- locks/unix/proc_mutex.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'locks') 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); } -- cgit v1.2.1