summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Hommel <wolfgang.hommel@unibw.de>2019-08-23 10:29:53 +0200
committerWolfgang Hommel <wolfgang.hommel@unibw.de>2019-08-23 10:29:53 +0200
commitba32d1b01c3c64964ad45011b29f7e9f8e23c1e5 (patch)
treeea09ef461459a5a537b4930ecf8616d0282dea4a
parent30ba0b852af5b4afde83f4106def5dc26d74d5ac (diff)
downloadlibfaketime-ba32d1b01c3c64964ad45011b29f7e9f8e23c1e5.tar.gz
Added FORCE_MONOTONIC_FIX CFLAG to avoid hangs on timedwait (#202 #142)
-rw-r--r--NEWS3
-rw-r--r--README6
-rw-r--r--src/Makefile11
-rw-r--r--src/libfaketime.c2
-rw-r--r--test/timetest.c2
5 files changed, 21 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 26a68a9..cba2534 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ Since 0.9.7:
- Updated glibc compatibility settings for various platforms
- Support for clock_nanosleep() with realtime and monotonic clocks
- Support for epoll_wait(), epoll_pwait(), and pselect()
+ - src/Makefile CFLAG FORCE_MONOTONIC_FIX should be set (only) on
+ platforms where the test program hangs forever at the
+ CLOCK_MONOTONIC test.
Since 0.9.6:
- Julien Gilli added an option to disable monotonic time faking
diff --git a/README b/README
index fd0f805..892484d 100644
--- a/README
+++ b/README
@@ -83,6 +83,12 @@ documentation whether it can be achieved by using libfaketime directly.
e.g., by checking whether certain environment variables are set or whether
libfaketime-specific files are present.
+* CLOCK_MONOTONIC test: Running "make test" performs a series of tests after
+ successful compilation of the libfaketime library. On some platforms, the
+ "CLOCK_MONOTONIC test" will apparently hang forever. If and only if this
+ happens on your platform, add the CFLAG -DFORCE_MONOTONIC_FIX to
+ src/Makefile and recompile libfaketime. Do not set FORCE_MONOTONIC_FIX on
+ platforms where the test does not hang.
3. Installation
---------------
diff --git a/src/Makefile b/src/Makefile
index e2f047a..07128c3 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -30,6 +30,13 @@
# FAKE_PTHREAD
# - Intercept pthread_cond_timedwait
#
+# FORCE_MONOTONIC_FIX
+# - If the test program hangs forever on
+# " pthread_cond_timedwait: CLOCK_MONOTONIC test
+# (Intentionally sleeping 1 second...) "
+# then add -DFORCE_MONOTONIC_FIX to CFLAGS and recompile.
+# (This is a platform-specific issue we cannot handle at run-time.)
+#
# MULTI_ARCH
# - If MULTI_ARCH is set, the faketime wrapper program will put a literal
# $LIB into the LD_PRELOAD environment variable it creates, which makes
@@ -50,8 +57,8 @@
# Change PREFIX to where you want libfaketime (libraries and wrapper binary) installed.
# LIBDIRNAME is relative to PREFIX. The default is to install into $PREFIX/lib/faketime,
# but you can set LIBDIRNAME to, e.g., /lib64 if you want to install it elsewhere.
-# LIBDIRNAME has been introduced to support MultiLib systems. Please do not change the
-# default value on MultiArch systems.
+# LIBDIRNAME has been introduced to support MultiLib systems. Please do not change the
+# default value on MultiArch systems.
#
# For testing in the current directory without installation, try make PREFIX= LIBDIRNAME='.'
diff --git a/src/libfaketime.c b/src/libfaketime.c
index 162df4f..9591ea1 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -3124,10 +3124,12 @@ int pthread_cond_timedwait_common(pthread_cond_t *cond, pthread_mutex_t *mutex,
fake time needs to be passed to pthread_cond_timedwait for
CLOCK_MONOTONIC. */
#ifndef __ARM_ARCH
+#ifndef FORCE_MONOTONIC_FIX
if(clk_id == CLOCK_MONOTONIC)
timespecadd(&faketime, &tdiff_actual, &tp);
else
#endif
+#endif
timespecadd(&realtime, &tdiff_actual, &tp);
tf = &tp;
diff --git a/test/timetest.c b/test/timetest.c
index 285d0cc..e9aa837 100644
--- a/test/timetest.c
+++ b/test/timetest.c
@@ -97,7 +97,7 @@ void* pthread_test(void* args)
timeToWait.tv_nsec = now.tv_nsec;
printf("pthread_cond_timedwait: CLOCK_MONOTONIC test\n");
- printf("(Intentionally sleeping 1 second...)\n");
+ printf("(Intentionally sleeping 1 second..., see docs about CLOCK_MONOTONIC test)\n");
fflush(stdout);
pthread_mutex_lock(&fakeMutex);