apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r671955 - in /apr/apr/trunk: CHANGES configure.in locks/unix/proc_mutex.c
Date Thu, 26 Jun 2008 17:18:04 GMT
Author: covener
Date: Thu Jun 26 10:18:03 2008
New Revision: 671955

URL: http://svn.apache.org/viewvc?rev=671955&view=rev
Log:
resolve testprocmutex failures on AIX and HP-UX by recognizing EACCES
in fcntl-based apr_proc_mutex_trylock().


Modified:
    apr/apr/trunk/CHANGES
    apr/apr/trunk/configure.in
    apr/apr/trunk/locks/unix/proc_mutex.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=671955&r1=671954&r2=671955&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Thu Jun 26 10:18:03 2008
@@ -1,6 +1,11 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.0
 
+  *) 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]
+ 
   *) Make sure WIN32 behaves the same as posix for file backed
      shared memory by removing the file on cleanup/remove.
      [Mladen Turk]

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?rev=671955&r1=671954&r2=671955&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Thu Jun 26 10:18:03 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/trunk/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/proc_mutex.c?rev=671955&r1=671954&r2=671955&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/proc_mutex.c (original)
+++ apr/apr/trunk/locks/unix/proc_mutex.c Thu Jun 26 10:18:03 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