Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions components/drivers/rtc/dev_alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
break;
case RT_ALARM_MINUTE:
{
alarm->wktime.tm_hour = now->tm_hour;
if (alarm->wktime.tm_sec == now->tm_sec)
/* wktime stores the next trigger time. Compare the complete time
* of day and only advance the next trigger after a hit, so that a
* reschedule caused by another alarm cannot fire this alarm early
* or corrupt the pending trigger time. */
if (sec_alarm == sec_now)
{
alarm->wktime.tm_hour = now->tm_hour;
alarm->wktime.tm_min = now->tm_min + 1;
if (alarm->wktime.tm_min > 59)
{
Expand All @@ -168,8 +172,8 @@ static void alarm_wakeup(struct rt_alarm *alarm, struct tm *now)
break;
case RT_ALARM_HOUR:
{
if ((alarm->wktime.tm_min == now->tm_min) &&
(alarm->wktime.tm_sec == now->tm_sec))
/* wktime stores the next trigger time; advance it only on a hit */
if (sec_alarm == sec_now)
{
alarm->wktime.tm_hour = now->tm_hour + 1;
if (alarm->wktime.tm_hour > 23)
Expand Down
Loading