From commits-return-9831-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Fri Jun 27 19:50:43 2008 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 26581 invoked from network); 27 Jun 2008 19:50:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Jun 2008 19:50:43 -0000 Received: (qmail 14537 invoked by uid 500); 27 Jun 2008 19:50:44 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 14489 invoked by uid 500); 27 Jun 2008 19:50:44 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 14479 invoked by uid 99); 27 Jun 2008 19:50:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2008 12:50:44 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Jun 2008 19:50:02 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 939AF2388A16; Fri, 27 Jun 2008 12:50:22 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@apr.apache.org From: covener@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080627195022.939AF2388A16@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_SYS_WAIT_H +#include +#endif +#if defined(HAVE_UNISTD_H) +#include +#endif +#include +#include + +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;