Merge "Fixed crash when timerfd_create failed"
This commit is contained in:
commit
3ee8c353cf
1 changed files with 12 additions and 5 deletions
|
@ -183,7 +183,7 @@ class LocTimerDelegate : public LocRankable {
|
||||||
: mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {}
|
: mClient(NULL), mLock(NULL), mFutureTime(delay), mContainer(NULL) {}
|
||||||
inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } }
|
inline ~LocTimerDelegate() { if (mLock) { mLock->drop(); mLock = NULL; } }
|
||||||
public:
|
public:
|
||||||
LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire);
|
LocTimerDelegate(LocTimer& client, struct timespec& futureTime, LocTimerContainer* container);
|
||||||
void destroyLocked();
|
void destroyLocked();
|
||||||
// LocRankable virtual method
|
// LocRankable virtual method
|
||||||
virtual int ranks(LocRankable& rankable);
|
virtual int ranks(LocRankable& rankable);
|
||||||
|
@ -472,11 +472,13 @@ bool LocTimerPollTask::run() {
|
||||||
/***************************LocTimerDelegate methods***************************/
|
/***************************LocTimerDelegate methods***************************/
|
||||||
|
|
||||||
inline
|
inline
|
||||||
LocTimerDelegate::LocTimerDelegate(LocTimer& client, struct timespec& futureTime, bool wakeOnExpire)
|
LocTimerDelegate::LocTimerDelegate(LocTimer& client,
|
||||||
|
struct timespec& futureTime,
|
||||||
|
LocTimerContainer* container)
|
||||||
: mClient(&client),
|
: mClient(&client),
|
||||||
mLock(mClient->mLock->share()),
|
mLock(mClient->mLock->share()),
|
||||||
mFutureTime(futureTime),
|
mFutureTime(futureTime),
|
||||||
mContainer(LocTimerContainer::get(wakeOnExpire)) {
|
mContainer(container) {
|
||||||
// adding the timer into the container
|
// adding the timer into the container
|
||||||
mContainer->add(*this);
|
mContainer->add(*this);
|
||||||
}
|
}
|
||||||
|
@ -556,8 +558,13 @@ bool LocTimer::start(unsigned int timeOutInMs, bool wakeOnExpire) {
|
||||||
futureTime.tv_sec += futureTime.tv_nsec / 1000000000;
|
futureTime.tv_sec += futureTime.tv_nsec / 1000000000;
|
||||||
futureTime.tv_nsec %= 1000000000;
|
futureTime.tv_nsec %= 1000000000;
|
||||||
}
|
}
|
||||||
mTimer = new LocTimerDelegate(*this, futureTime, wakeOnExpire);
|
|
||||||
|
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
|
// if mTimer is non 0, success should be 0; or vice versa
|
||||||
|
}
|
||||||
success = (NULL != mTimer);
|
success = (NULL != mTimer);
|
||||||
}
|
}
|
||||||
mLock->unlock();
|
mLock->unlock();
|
||||||
|
|
Loading…
Reference in a new issue