timer bug fix

when a ticking timer is stopped, currently kernel doesn't
get updated with the next immediate timer's interval. As a
result, kernel timer will expire sooner (with the stopped
timer's interval), and the next timer's client is notified
for this expiration.

Change-Id: I0d67d1418cb9bfe7f70ae71252901d4c6bb699b3
CRs-Fixed: 909776
This commit is contained in:
Kevin Tang 2015-09-15 19:02:58 -07:00
parent 9957a19f5f
commit 088a127c31
2 changed files with 8 additions and 4 deletions

View file

@ -199,7 +199,7 @@ bool LocHeapNode::checkNodes() {
int totalSize = mSize; int totalSize = mSize;
if (mLeft) { if (mLeft) {
// check the consistency of left subtree // check the consistency of left subtree
if (!outRanks(*mLeft) || !mLeft->checkNodes()) { if (mLeft->outRanks(*this) || !mLeft->checkNodes()) {
return false; return false;
} }
// subtract the size of left subtree (with subtree head) // subtract the size of left subtree (with subtree head)
@ -208,7 +208,7 @@ bool LocHeapNode::checkNodes() {
if (mRight) { if (mRight) {
// check the consistency of right subtree // check the consistency of right subtree
if (!outRanks(*mRight) || !mRight->checkNodes()) { if (mRight->outRanks(*this) || !mRight->checkNodes()) {
return false; return false;
} }
// subtract the size of right subtree (with subtree head) // subtract the size of right subtree (with subtree head)

View file

@ -342,8 +342,12 @@ void LocTimerContainer::remove(LocTimerDelegate& timer) {
LocMsg(), mTimerContainer(&container), mTimer(&timer) {} LocMsg(), mTimerContainer(&container), mTimer(&timer) {}
inline virtual void proc() const { inline virtual void proc() const {
LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer(); LocTimerDelegate* priorTop = mTimerContainer->getSoonestTimer();
if (NULL != ((LocHeap*)mTimerContainer)->remove((LocRankable&)*mTimer)) { // update soonest timer only if mTimer is actually removed from mTimerContainer
mTimerContainer->updateSoonestTime(priorTop); // AND mTimer is not priorTop.
if (priorTop == ((LocHeap*)mTimerContainer)->remove((LocRankable&)*mTimer)) {
// if passing in NULL, we tell updateSoonestTime to update kernel with
// the current top timer interval.
mTimerContainer->updateSoonestTime(NULL);
} }
delete mTimer; delete mTimer;
} }