apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1610993 - in /apr/apr/branches/1.6.x: ./ locks/unix/proc_mutex.c
Date Wed, 16 Jul 2014 13:11:07 GMT
Author: trawick
Date: Wed Jul 16 13:11:07 2014
New Revision: 1610993

URL: http://svn.apache.org/r1610993
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.6.x/   (props changed)
    apr/apr/branches/1.6.x/locks/unix/proc_mutex.c

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

Modified: apr/apr/branches/1.6.x/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/locks/unix/proc_mutex.c?rev=1610993&r1=1610992&r2=1610993&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/locks/unix/proc_mutex.c (original)
+++ apr/apr/branches/1.6.x/locks/unix/proc_mutex.c Wed Jul 16 13:11:07 2014
@@ -125,7 +125,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 */
@@ -133,7 +135,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) {
@@ -151,7 +155,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;
@@ -160,7 +169,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