summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2017-04-06 21:57:29 +0000
committerYann Ylavic <ylavic@apache.org>2017-04-06 21:57:29 +0000
commitc93e1021f0bffe93d548b372b10704b8584c58f9 (patch)
tree40af729ab76afc3f2785b5f30e60b246d2dfe4ba /test
parentcb035cfba978f8c8e92b0b013543ea56b9a094f1 (diff)
downloadapr-c93e1021f0bffe93d548b372b10704b8584c58f9.tar.gz
Merge r1790296, r1790302, r1790303, r1790304, r1790330, r1790331, r1790436, r1790439, r1790444, r1790446 from trunk:
Follow up to r1667900: semtimedop() should be passed a relative timeout rather then absolute. semtimedop() takes a delta time, so accept what is given as the "time remaining" rr1790301 Use our "portable" versions Make clear this is a delta timeout locks: when pthread_mutex_timedlock() isn't available, fall back to an implementation based on pthread_cond_timedwait() when possible. Avoid a compiler warning by using system's errno. locks: follow up to r1790330. When no native timedlock is available, fall back to a common/generic spin sleep proc_mutex_spinsleep_timedacquire() based on the configured APR_USE_*_SERIALIZE trylock. Otherwise, choose the best timedlock mechanism in the following order: 1. PTHREAD if HAVE_PTHREAD_MUTEX_ROBUST && (HAVE_PTHREAD_MUTEX_TIMEDLOCK || HAVE_PTHREAD_CONDATTR_SETPSHARED) 2. SYSV if HAVE_SEMTIMEDOP 3. POSIX if HAVE_SEM_TIMEDWAIT 4. The one of APR_USE_*_SERIALIZE, hence possibly non-robust and/or spinning with the same robustness as the underlying apr_proc_mutex_trylock() call. apr_proc_mutex_timedlock() won't return ENOTIMPL anymore. locks: follow up to r1790330 and r1790436. unix/misc.c is not needed anymore since we use apr_proc_mutex_trylock() directly. locks: follow up to r1790330. No functional change, more helpers/macros to help identify struct proc_pthread_mutex_t members. locks: follow up to r1790330. Don't try to access proc_pthread_mutex_t's condvar if the mutex was _put[_ex]() and not _create()d, this is a real pthread_mutex_t. Submitted by: ylavic, jim, jim, jim, ylavic, ylavic, ylavic, ylavic, ylavic, ylavic git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1790474 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test')
-rw-r--r--test/testprocmutex.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/testprocmutex.c b/test/testprocmutex.c
index 599d58520..3aff25b88 100644
--- a/test/testprocmutex.c
+++ b/test/testprocmutex.c
@@ -20,6 +20,7 @@
#include "apr_proc_mutex.h"
#include "apr_errno.h"
#include "apr_general.h"
+#include "apr_strings.h"
#include "apr_getopt.h"
#include <stdio.h>
#include <stdlib.h>
@@ -155,6 +156,19 @@ static void test_exclusive(abts_case *tc, const char *lockname,
else {
APR_ASSERT_SUCCESS(tc, "check for trylock", rv);
+ for (n = 0; n < 2; n++) {
+ rv = apr_proc_mutex_trylock(proc_lock);
+ /* Some mech (eg. flock or fcntl) may succeed when the
+ * lock is re-acquired in the same process.
+ */
+ if (rv != APR_SUCCESS) {
+ ABTS_ASSERT(tc,
+ apr_psprintf(p, "%s_trylock() should be busy => %pm",
+ mech->name, &rv),
+ APR_STATUS_IS_EBUSY(rv));
+ }
+ }
+
rv = apr_proc_mutex_unlock(proc_lock);
APR_ASSERT_SUCCESS(tc, "unlock after trylock check", rv);
@@ -179,6 +193,19 @@ static void test_exclusive(abts_case *tc, const char *lockname,
else {
APR_ASSERT_SUCCESS(tc, "check for timedlock", rv);
+ for (n = 0; n < 2; n++) {
+ rv = apr_proc_mutex_timedlock(proc_lock, 1, 0);
+ /* Some mech (eg. flock or fcntl) may succeed when the
+ * lock is re-acquired in the same process.
+ */
+ if (rv != APR_SUCCESS) {
+ ABTS_ASSERT(tc,
+ apr_psprintf(p, "%s_timedlock() should time out => %pm",
+ mech->name, &rv),
+ APR_STATUS_IS_TIMEUP(rv));
+ }
+ }
+
rv = apr_proc_mutex_unlock(proc_lock);
APR_ASSERT_SUCCESS(tc, "unlock after timedlock check", rv);