Skip to content

Commit f22332b

Browse files
Sapna Todwalkdopen
authored andcommitted
Set an upper limit to next wakeup time
:Release Notes: Set next wakeup time to 10 sec if it exceeds the max value of 7 days. :Detailed Notes: Since sleepd starts much earlier in the boot sequence, when it tries to read the system time its set to some invalid time, thereby causing the wakeup time to overflow the max value that an unsigned int can hold and at times making it negative causing GSource event loop to trigger again and again until the system time is set to an appropriate value. So to fix this issue, sleepd now sets up an upper limit to the value of the next wakeup time to 7 days (because the next alarm can never be set for a time beyond one week), and if the value exceeds that, its set to 10 sec, so that it can come back up after 10 sec and recalculate the alarm expiry then by when the system time would also have been set correctly. :Testing Performed: Verified that with this change sleepd doesnt trigger unnecessary SQLite reads for recalculating alarms and the bootchart shows that sleepd isnt consuming large amount of CPU cycles as it was doing before. :Issues Addressed: [GF-41100] sleepd consuming large amout of CPU cycles during boot Open-webOS-DCO-1.0-Signed-off-by: Sapna Todwal <sapna.todwal@lge.com> Change-Id: I3c2a0d66ccaa81573b6e03fd13c996575de0d917 Reviewed-on: https://g2g.palm.com/4485 Reviewed-by: DCO Verification Reviewed-by: Keith Derrick <keith.derrick@lge.com> Tested-by: Sapna Todwal <sapna.todwal@lge.com>
1 parent 6a8b657 commit f22332b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

‎src/alarms/timeout_alarm.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ bool queue_next_wakeup()
579579
return _queue_next_wakeup(false);
580580
}
581581

582+
/* If next wakeup time exceeds 7 days its due to incorrect system time,
583+
so set the minimum wakeup interval to 10 sec after which sleepd can
584+
again check if the next wakeup time is sane (less than 7 days)
585+
and set it accordingly */
586+
587+
#define MAX_WAKEUP_SECS 7*24*60*60
588+
#define MIN_WAKEUP_SECS 10
589+
582590
/**
583591
* @brief Queues a timer for non-wakeup timeouts.
584592
*
@@ -626,6 +634,10 @@ _queue_next_timeout()
626634
{
627635
wakeInSeconds = 0;
628636
}
637+
else if(wakeInSeconds > MAX_WAKEUP_SECS)
638+
{
639+
wakeInSeconds = MIN_WAKEUP_SECS;
640+
}
629641

630642
g_timer_source_set_interval_seconds(sTimerCheck, wakeInSeconds, true);
631643
}

0 commit comments

Comments
 (0)