apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r672368 - in /apr/apr/branches/1.3.x: CHANGES configure.in locks/unix/proc_mutex.c
Date Fri, 27 Jun 2008 19:50:22 GMT
Author: covener
Date: Fri Jun 27 12:50:22 2008
New Revision: 672368

URL: http://svn.apache.org/viewvc?rev=672368&view=rev
Log:
backport r671955

resolve testprocmutex failures on AIX and HP-UX by recognizing EACCES
in fcntl-based apr_proc_mutex_trylock().


Modified:
    apr/apr/branches/1.3.x/CHANGES
    apr/apr/branches/1.3.x/configure.in
    apr/apr/branches/1.3.x/locks/unix/proc_mutex.c

Modified: apr/apr/branches/1.3.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/CHANGES?rev=672368&r1=672367&r2=672368&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.3.x/CHANGES [utf-8] Fri Jun 27 12:50:22 2008
@@ -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

Modified: apr/apr/branches/1.3.x/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/configure.in?rev=672368&r1=672367&r2=672368&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/configure.in (original)
+++ apr/apr/branches/1.3.x/configure.in Fri Jun 27 12:50:22 2008
@@ -1886,6 +1886,70 @@
         ;;
 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)

Modified: apr/apr/branches/1.3.x/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.3.x/locks/unix/proc_mutex.c?rev=672368&r1=672367&r2=672368&view=diff
==============================================================================
--- apr/apr/branches/1.3.x/locks/unix/proc_mutex.c (original)
+++ apr/apr/branches/1.3.x/locks/unix/proc_mutex.c Fri Jun 27 12:50:22 2008
@@ -565,7 +565,11 @@
         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;



Mime
View raw message