summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2014-07-16 13:11:07 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2014-07-16 13:11:07 +0000
commit7ea3bad4e1a419eb37affcd1c457798f818e0ac0 (patch)
tree01bb8a83d00ad73538fb572f45b18872f6ede3d4 /locks
parentfb57a66e312b5c879335ab6dcba92b0778792b19 (diff)
downloadlibapr-7ea3bad4e1a419eb37affcd1c457798f818e0ac0.tar.gz
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(). git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1610993 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r--locks/unix/proc_mutex.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index cb6bad55e..7eff5e3f3 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -125,7 +125,9 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
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_create(apr_proc_mutex_t *new_mutex,
} 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_create(apr_proc_mutex_t *new_mutex,
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_acquire(apr_proc_mutex_t *mutex)
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;
}