diff options
author | covener <covener@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-27 19:50:22 +0000 |
---|---|---|
committer | covener <covener@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-27 19:50:22 +0000 |
commit | 7a1b61d9f0a3d832f013b40b82cb7d53a12f3130 (patch) | |
tree | cdc2f264969e22a340eb14ec95a6a7d46d51e98b | |
parent | 177e16af3a59621b7ee24d24f130f66f8e4fd385 (diff) | |
download | libapr-7a1b61d9f0a3d832f013b40b82cb7d53a12f3130.tar.gz |
backport r671955
resolve testprocmutex failures on AIX and HP-UX by recognizing EACCES
in fcntl-based apr_proc_mutex_trylock().
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.3.x@672368 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | configure.in | 64 | ||||
-rw-r--r-- | locks/unix/proc_mutex.c | 4 |
3 files changed, 72 insertions, 0 deletions
@@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes for APR 1.3.3 + *) Use proper return code for fcntl-based apr_proc_mutex_trylock() + on platforms that return EACCES instead of EAGAIN when the lock + is already held (AIX, HP-UX). + [Eric Covener] Changes for APR 1.3.2 diff --git a/configure.in b/configure.in index 6b7ce59cf..1b688bcf3 100644 --- a/configure.in +++ b/configure.in @@ -1886,6 +1886,70 @@ case $ac_decision in ;; esac +if test $hasfcntlser = "1"; then +AC_MSG_CHECKING(if fcntl returns EACCES when F_SETLK is already held) +AC_TRY_RUN([ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#ifdef HAVE_SYS_WAIT_H +#include <sys/wait.h> +#endif +#if defined(HAVE_UNISTD_H) +#include <unistd.h> +#endif +#include <fcntl.h> +#include <errno.h> + +int fd; +struct flock proc_mutex_lock_it = {0}; +const char *fname = "conftest.fcntl"; + +int main() +{ + int rc, status;; + proc_mutex_lock_it.l_whence = SEEK_SET; /* from current point */ + proc_mutex_lock_it.l_type = F_WRLCK; /* set exclusive/write lock */ + + fd = creat(fname, S_IRWXU); + unlink(fname); + + if (rc = lockit()) { + exit(-1); + } + + if (fork()) { + wait(&status); + } + else { + return(lockit()); + } + + close(fd); + exit(WEXITSTATUS(status) != EACCES); +} + +int lockit() { + int rc; + do { + rc = fcntl(fd, F_SETLK, &proc_mutex_lock_it); + } while ( rc < 0 && errno == EINTR); + + return (rc < 0) ? errno : 0; +}], [apr_fcntl_tryacquire_eacces=1], [apr_fcntl_tryacquire_eacces=0], [apr_fcntl_tryacquire_eacces=0]) +fi + +if test "$apr_fcntl_tryacquire_eacces" = "1"; then + AC_DEFINE(FCNTL_TRYACQUIRE_EACCES, 1, [Define if fcntl returns EACCES when F_SETLK is already held]) +fi + + AC_SUBST(hasflockser) AC_SUBST(hassysvser) AC_SUBST(hasposixser) diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c index 9358e68e1..e433230a8 100644 --- a/locks/unix/proc_mutex.c +++ b/locks/unix/proc_mutex.c @@ -565,7 +565,11 @@ static apr_status_t proc_mutex_fcntl_tryacquire(apr_proc_mutex_t *mutex) rc = fcntl(mutex->interproc->filedes, F_SETLK, &proc_mutex_lock_it); } while (rc < 0 && errno == EINTR); if (rc < 0) { +#if FCNTL_TRYACQUIRE_EACCES + if (errno == EACCES) { +#else if (errno == EAGAIN) { +#endif return APR_EBUSY; } return errno; |