apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1611000 - in /apr/apr/branches/1.5.x: ./ CHANGES locks/unix/proc_mutex.c
Date Wed, 16 Jul 2014 13:26:18 GMT
Author: trawick
Date: Wed Jul 16 13:26:17 2014
New Revision: 1611000

URL: http://svn.apache.org/r1611000
Log:
Merge r1610854 from trunk:

Resolve failures with the POSIX sem implementation of APR
process mutexes (and thus global mutexes) in environments which
receive signals.

EINTR is now handled on the sem_* calls that are documented as
exposing EINTR in the Linux, FreeBSD, and/or Solaris docs.

There are a few other calls that haven't been updated: 
sem_unlink(), sem_post(), and sem_close().

Modified:
    apr/apr/branches/1.5.x/   (props changed)
    apr/apr/branches/1.5.x/CHANGES
    apr/apr/branches/1.5.x/locks/unix/proc_mutex.c

Propchange: apr/apr/branches/1.5.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1610854

Modified: apr/apr/branches/1.5.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/CHANGES?rev=1611000&r1=1610999&r2=1611000&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.5.x/CHANGES [utf-8] Wed Jul 16 13:26:17 2014
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.5.2
 
+  *) apr_global_mutex/apr_proc_mutex: Resolve failures with the 
+     POSIX sem implementation in environments which receive signals.
+     [Jeff Trawick]
+
   *) apr_skiplist: Fix potential corruption of skiplists leading to 
      results or crashes. [Takashi Sato <takashi tks st>, Eric Covener]
      PR 56654.

Modified: apr/apr/branches/1.5.x/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/locks/unix/proc_mutex.c?rev=1611000&r1=1610999&r2=1611000&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/locks/unix/proc_mutex.c (original)
+++ apr/apr/branches/1.5.x/locks/unix/proc_mutex.c Wed Jul 16 13:26:17 2014
@@ -114,7 +114,9 @@ static apr_status_t proc_mutex_posix_cre
         usec = apr_time_usec(now);
         apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec);
     }
-    psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+    do {
+        psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+    } while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
     if (psem == (sem_t *)SEM_FAILED) {
         if (errno == ENAMETOOLONG) {
             /* Oh well, good try */
@@ -122,7 +124,9 @@ static apr_status_t proc_mutex_posix_cre
         } else {
             return errno;
         }
-        psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+        do {
+            psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+        } while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
     }
 
     if (psem == (sem_t *)SEM_FAILED) {
@@ -140,7 +144,12 @@ static apr_status_t proc_mutex_posix_cre
 
 static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
 {
-    if (sem_wait(mutex->psem_interproc) < 0) {
+    int rc;
+
+    do {
+        rc = sem_wait(mutex->psem_interproc);
+    } while (rc < 0 && errno == EINTR);
+    if (rc < 0) {
         return errno;
     }
     mutex->curr_locked = 1;
@@ -149,7 +158,12 @@ static apr_status_t proc_mutex_posix_acq
 
 static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex)
 {
-    if (sem_trywait(mutex->psem_interproc) < 0) {
+    int rc;
+
+    do {
+        rc = sem_trywait(mutex->psem_interproc);
+    } while (rc < 0 && errno == EINTR);
+    if (rc < 0) {
         if (errno == EAGAIN) {
             return APR_EBUSY;
         }



Mime
View raw message