summaryrefslogtreecommitdiffstats
path: root/libutils/SystemClock.cpp
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-12-12 15:16:39 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2016-12-12 15:16:39 +0100
commitbd9837c3559f8e545bdb6bd4010b0e2d6e6297c4 (patch)
tree4af1be2ac6814a892f91168089f6d3980bcf6931 /libutils/SystemClock.cpp
parent870d7cfb19f49ced89117b403972eef4a05faf08 (diff)
parent656154a5b4127370f7317852e224a9121c6beed3 (diff)
downloadsystem_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.zip
system_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.tar.gz
system_core-bd9837c3559f8e545bdb6bd4010b0e2d6e6297c4.tar.bz2
Merge branch 'cm-13.0' of https://github.com/CyanogenMod/android_system_core into replicant-6.0
Diffstat (limited to 'libutils/SystemClock.cpp')
-rw-r--r--libutils/SystemClock.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libutils/SystemClock.cpp b/libutils/SystemClock.cpp
index c3b5d74..28ea817 100644
--- a/libutils/SystemClock.cpp
+++ b/libutils/SystemClock.cpp
@@ -121,9 +121,11 @@ int64_t elapsedRealtimeNano()
#endif
static int s_fd = -1;
+ bool need_unlock = false;
if (clock_method < 0) {
pthread_mutex_lock(&clock_lock);
+ need_unlock = true;
}
if (clock_method < 0 || clock_method == METHOD_IOCTL) {
@@ -143,6 +145,8 @@ int64_t elapsedRealtimeNano()
checkTimeStamps(timestamp, &prevTimestamp, &prevMethod, METHOD_IOCTL);
if (clock_method < 0) {
clock_method = METHOD_IOCTL;
+ }
+ if (need_unlock) {
pthread_mutex_unlock(&clock_lock);
}
return timestamp;
@@ -159,6 +163,8 @@ int64_t elapsedRealtimeNano()
METHOD_CLOCK_GETTIME);
if (clock_method < 0) {
clock_method = METHOD_CLOCK_GETTIME;
+ }
+ if (need_unlock) {
pthread_mutex_unlock(&clock_lock);
}
return timestamp;
@@ -173,6 +179,8 @@ int64_t elapsedRealtimeNano()
METHOD_SYSTEMTIME);
if (clock_method < 0) {
clock_method = METHOD_SYSTEMTIME;
+ }
+ if (need_unlock) {
pthread_mutex_unlock(&clock_lock);
}
return timestamp;