summaryrefslogtreecommitdiff
path: root/utils/LocTimer.cpp
diff options
context:
space:
mode:
authorBhavna Sharma <sbhavna@codeaurora.org>2015-08-26 11:26:46 -0700
committerBhavna Sharma <sbhavna@codeaurora.org>2015-08-27 10:29:54 -0700
commit5e7710897247c8c8da6bed8cdcc7dc43698e2937 (patch)
tree93818543b2ea78e554dd0220eb88d127c8d0c59f /utils/LocTimer.cpp
parentf2f492bd5bc336ba68cbdd09383f07d2e1c086dd (diff)
downloadgps-5e7710897247c8c8da6bed8cdcc7dc43698e2937.tar.gz
Fix for timerfd_create on older kernel revisions
BOOTTIME_ALARM and BOOTTIME were added to timerfd_create in kernel version 3.11 and 3.15 respectively. But for targets still on older kernel version we fallback on MONOTONIC. CRs-Fixed: 897805 Change-Id: I47d9780d69ce5ee8c183c84baa93ea3c1a00db57
Diffstat (limited to 'utils/LocTimer.cpp')
-rw-r--r--utils/LocTimer.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/utils/LocTimer.cpp b/utils/LocTimer.cpp
index 277a813..524897b 100644
--- a/utils/LocTimer.cpp
+++ b/utils/LocTimer.cpp
@@ -103,7 +103,7 @@ class LocTimerContainer : public LocHeap {
// Poll task to provide epoll call and threading to poll.
static LocTimerPollTask* mPollTask;
// timer / alarm fd
- const int mDevFd;
+ int mDevFd;
// ctor
LocTimerContainer(bool wakeOnExpire);
// dtor
@@ -210,6 +210,13 @@ LocTimerPollTask* LocTimerContainer::mPollTask = NULL;
// HwTimer (alarm), when wakeOnExpire is false.
LocTimerContainer::LocTimerContainer(bool wakeOnExpire) :
mDevFd(timerfd_create(wakeOnExpire ? CLOCK_BOOTTIME_ALARM : CLOCK_BOOTTIME, 0)) {
+
+ if ((-1 == mDevFd) && (errno == EINVAL)) {
+ LOC_LOGW("%s: timerfd_create failure, fallback to CLOCK_MONOTONIC - %s",
+ __FUNCTION__, strerror(errno));
+ mDevFd = timerfd_create(CLOCK_MONOTONIC, 0);
+ }
+
if (-1 != mDevFd) {
// ensure we have the necessary resources created
LocTimerContainer::getPollTaskLocked();