Merge "Fixed crash when timerfd_create failed"
diff --git a/utils/LocTimer.cpp b/utils/LocTimer.cpp
index 4de6b40..c08bd35 100644
--- a/utils/LocTimer.cpp
+++ b/utils/LocTimer.cpp
@@ -183,7 +183,7 @@
: mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {}
inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } }
public:
- LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire);
+ LocTimerDelegate(LocTimer& client, struct timespec& futureTime, LocTimerContainer* container);
void destroyLocked();
// LocRankable virtual method
virtual int ranks(LocRankable& rankable);
@@ -472,11 +472,13 @@
/***************************LocTimerDelegate methods***************************/
inline
-LocTimerDelegate::LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire)
+LocTimerDelegate::LocTimerDelegate(LocTimer& client,
+ struct timespec& futureTime,
+ LocTimerContainer* container)
: mClient(&client),
mLock(mClient->mLock->share()),
mFutureTime(futureTime),
- mContainer(LocTimerContainer::get(wakeOnExpire)) {
+ mContainer(container) {
// adding the timer into the container
mContainer->add(*this);
}
@@ -556,8 +558,13 @@
futureTime.tv_sec += futureTime.tv_nsec / 1000000000;
futureTime.tv_nsec %= 1000000000;
}
- mTimer = new LocTimerDelegate(*this, futureTime, wakeOnExpire);
- // if mTimer is non 0, success should be 0; or vice versa
+
+ LocTimerContainer* container;
+ container = LocTimerContainer::get(wakeOnExpire);
+ if (NULL != container) {
+ mTimer = new LocTimerDelegate(*this, futureTime, container);
+ // if mTimer is non 0, success should be 0; or vice versa
+ }
success = (NULL != mTimer);
}
mLock->unlock();