[evolution/gnome-3-26] Bug 696047 - [alarm-notify] Busy loop on midnight and DST change



commit 1637c9698ce36a8e68ff08124d3fa4652f248ef7
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 16 19:02:04 2017 +0200

    Bug 696047 - [alarm-notify] Busy loop on midnight and DST change

 src/calendar/alarm-notify/alarm-queue.c |   13 ++++++++++++-
 src/calendar/alarm-notify/alarm.c       |    2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/alarm-notify/alarm-queue.c b/src/calendar/alarm-notify/alarm-queue.c
index ed2a528..f3c02d6 100644
--- a/src/calendar/alarm-notify/alarm-queue.c
+++ b/src/calendar/alarm-notify/alarm-queue.c
@@ -235,6 +235,7 @@ static void
 queue_midnight_refresh (void)
 {
        icaltimezone *zone;
+       time_t now;
 
        if (midnight_refresh_id != NULL) {
                alarm_remove (midnight_refresh_id);
@@ -242,7 +243,14 @@ queue_midnight_refresh (void)
        }
 
        zone = config_data_get_timezone ();
-       midnight = time_day_end_with_zone (time (NULL), zone);
+       now = time (NULL);
+       midnight = time_day_end_with_zone (now, zone);
+
+       while (midnight <= now) {
+               now += 60 * 60; /* increment one day */
+               midnight = time_day_end_with_zone (now, zone);
+               debug (("Required correction of the day end, now at %s", e_ctime (&midnight)));
+       }
 
        debug (("Refresh at %s", e_ctime (&midnight)));
 
@@ -300,6 +308,9 @@ midnight_refresh_cb (gpointer alarm_id,
 {
        struct _midnight_refresh_msg *msg;
 
+       if (midnight_refresh_id == alarm_id)
+               midnight_refresh_id = NULL;
+
        msg = g_slice_new0 (struct _midnight_refresh_msg);
        msg->header.func = (MessageFunc) midnight_refresh_async;
        msg->remove = TRUE;
diff --git a/src/calendar/alarm-notify/alarm.c b/src/calendar/alarm-notify/alarm.c
index 1cca963..1240e0d 100644
--- a/src/calendar/alarm-notify/alarm.c
+++ b/src/calendar/alarm-notify/alarm.c
@@ -248,7 +248,7 @@ alarm_remove (gpointer alarm)
 
        l = g_list_find (alarms, ar);
        if (!l) {
-               g_warning (G_STRLOC ": Requested removal of nonexistent alarm!");
+               debug ((G_STRLOC ": Requested removal of nonexistent alarm!"));
                return;
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]