From e171b9324b8f9ff93bb3ea53543f9face7dc5638 Mon Sep 17 00:00:00 2001 From: trawick Date: Sat, 7 Jun 2003 19:45:10 +0000 Subject: Add proc_mutex_lockfile() for retrieving the name of the file associated with a mutex. This is used in Apache to simplify the effort of getting permissions set properly on mutexes that will be created as root but used as non-root. For flock-based mutexes, chown() needs to be performed on the mutex file. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64531 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ include/apr_proc_mutex.h | 7 +++++++ locks/beos/proc_mutex.c | 5 +++++ locks/netware/proc_mutex.c | 5 +++++ locks/os2/proc_mutex.c | 5 +++++ locks/unix/proc_mutex.c | 12 ++++++++++++ locks/win32/proc_mutex.c | 5 +++++ 7 files changed, 42 insertions(+) diff --git a/CHANGES b/CHANGES index 1ef63a9fc..48b02fa8a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with APR 0.9.4 + *) Add apr_proc_mutex_lockfile() for retrieving the name of the + file associated with a mutex. [Jeff Trawick] + *) Don't require the lock file name to be passed into apr_proc_mutex_child_init() or apr_global_mutex_child_init(). This allows child init to work when the lock file was a temp diff --git a/include/apr_proc_mutex.h b/include/apr_proc_mutex.h index 197da270a..6cc6740ff 100644 --- a/include/apr_proc_mutex.h +++ b/include/apr_proc_mutex.h @@ -170,6 +170,13 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex); */ APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex); +/** + * Return the name of the lockfile for the mutex, or NULL + * if the mutex doesn't use a lock file + */ + +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex); + /** * Display the name of the mutex, as it relates to the actual method used. * This matches the valid options for Apache's AcceptMutex directive diff --git a/locks/beos/proc_mutex.c b/locks/beos/proc_mutex.c index 405a0b15e..bf4d7c3e5 100644 --- a/locks/beos/proc_mutex.c +++ b/locks/beos/proc_mutex.c @@ -157,6 +157,11 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) return stat; } +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +{ + return NULL; +} + APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) { return "beossem"; diff --git a/locks/netware/proc_mutex.c b/locks/netware/proc_mutex.c index 075d98305..789f0f81e 100644 --- a/locks/netware/proc_mutex.c +++ b/locks/netware/proc_mutex.c @@ -120,6 +120,11 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) return APR_ENOLOCK; } +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +{ + return NULL; +} + APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) { return "netwarethread"; diff --git a/locks/os2/proc_mutex.c b/locks/os2/proc_mutex.c index 23f0bdd69..3a3c848aa 100644 --- a/locks/os2/proc_mutex.c +++ b/locks/os2/proc_mutex.c @@ -93,6 +93,11 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *vmutex) return apr_proc_mutex_destroy(mutex); } +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +{ + return NULL; +} + APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) { return "os2sem"; diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index 2f2a1a626..1fc630c38 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -877,6 +877,18 @@ APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) return mutex->meth->name; } +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +{ + /* posix sems use the fname field but don't use a file, + * so be careful + */ + if (!strcmp(mutex->meth->name, "flock") || + !strcmp(mutex->meth->name, "fcntl")) { + return mutex->fname; + } + return NULL; +} + APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex) /* Implement OS-specific accessors defined in apr_portable.h */ diff --git a/locks/win32/proc_mutex.c b/locks/win32/proc_mutex.c index 37a1d0cec..b490299ff 100644 --- a/locks/win32/proc_mutex.c +++ b/locks/win32/proc_mutex.c @@ -205,6 +205,11 @@ APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex) return stat; } +APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex) +{ + return NULL; +} + APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex) { return mutex->fname; -- cgit v1.2.1