File 0009-Merge-r1610854-from-trunk.patch of Package libapr1
From eb5e8e0dd4c6295905e8c4fe4f1cfec42d8ad761 Mon Sep 17 00:00:00 2001
From: Jeff Trawick <trawick@apache.org>
Date: Wed, 16 Jul 2014 13:26:17 +0000
Subject: [PATCH 09/13] 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: https://svn.apache.org/repos/asf/apr/apr/branches/1.5.x@1611000 13f79535-47bb-0310-9956-ffa450edef68
---
CHANGES | 4 ++++
locks/unix/proc_mutex.c | 22 ++++++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index fa8a872..32012a7 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -114,7 +114,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 */
@@ -122,7 +124,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) {
@@ -140,7 +144,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;
@@ -149,7 +158,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;
}
--
2.0.4