You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2014/07/15 23:27:27 UTC
svn commit: r1610854 - /apr/apr/trunk/locks/unix/proc_mutex.c
Author: trawick
Date: Tue Jul 15 21:27:27 2014
New Revision: 1610854
URL: http://svn.apache.org/r1610854
Log:
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/trunk/locks/unix/proc_mutex.c
Modified: apr/apr/trunk/locks/unix/proc_mutex.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/locks/unix/proc_mutex.c?rev=1610854&r1=1610853&r2=1610854&view=diff
==============================================================================
--- apr/apr/trunk/locks/unix/proc_mutex.c (original)
+++ apr/apr/trunk/locks/unix/proc_mutex.c Tue Jul 15 21:27:27 2014
@@ -115,7 +115,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 */
@@ -123,7 +125,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) {
@@ -141,7 +145,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;
@@ -150,7 +159,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;
}