From: Yabin Cui Date: Wed, 13 Jul 2016 22:53:25 +0000 (-0700) Subject: Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC. X-Git-Tag: android-x86-7.1-r1~34 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a36b574011;p=android-x86%2Fbionic.git Force pthread_cond_timedwait_relative_np using CLOCK_MONOTONIC. Previous patch changed pthread_cond_timedwait_relative_np to use CLOCK_REALTIME, which causes app compatibility problem. So change it back to CLOCK_MONOTONIC. Bug: 30106240 Change-Id: I8e04058e92ede098f4f9f8d133f094001921441e (cherry picked from commit fe4a4d8f67cf84b0b10d6c689f356229e057603b) --- diff --git a/libc/bionic/pthread_cond.cpp b/libc/bionic/pthread_cond.cpp index d36426c16..c35d9f159 100644 --- a/libc/bionic/pthread_cond.cpp +++ b/libc/bionic/pthread_cond.cpp @@ -224,16 +224,18 @@ extern "C" int pthread_cond_timedwait_monotonic_np(pthread_cond_t* cond_interfac return pthread_cond_timedwait_monotonic(cond_interface, mutex, abs_timeout); } +// Force this function using CLOCK_MONOTONIC because it was always using +// CLOCK_MONOTONIC in history. extern "C" int pthread_cond_timedwait_relative_np(pthread_cond_t* cond_interface, pthread_mutex_t* mutex, const timespec* rel_timeout) { timespec ts; timespec* abs_timeout = nullptr; if (rel_timeout != nullptr) { - absolute_timespec_from_timespec(ts, *rel_timeout, CLOCK_REALTIME); + absolute_timespec_from_timespec(ts, *rel_timeout, CLOCK_MONOTONIC); abs_timeout = &ts; } - return __pthread_cond_timedwait(__get_internal_cond(cond_interface), mutex, true, abs_timeout); + return __pthread_cond_timedwait(__get_internal_cond(cond_interface), mutex, false, abs_timeout); } extern "C" int pthread_cond_timeout_np(pthread_cond_t* cond_interface,