Commit 32039961 authored by Jan Včelák's avatar Jan Včelák 🚀

fix: lost notify message during zone transfer

closes #344
parent af5660b0
......@@ -279,8 +279,11 @@ void zone_events_schedule_at(zone_t *zone, zone_event_type_t type, time_t time)
zone_events_t *events = &zone->events;
pthread_mutex_lock(&events->mx);
event_set_time(events, type, time);
reschedule(events);
time_t current = event_get_time(events, type);
if (time == 0 || current == 0 || time < current) {
event_set_time(events, type, time);
reschedule(events);
}
pthread_mutex_unlock(&events->mx);
}
......
......@@ -104,6 +104,10 @@ void zone_events_enqueue(struct zone *zone, zone_event_type_t type);
/*!
* \brief Schedule new zone event to absolute time.
*
* If the event is already scheduled, the new time will be set only if the
* new time is earlier than the currently scheduled one. An exception is
* a zero time, which causes event cancellation.
*
* \param zone Zone to schedule new event for.
* \param type Type of event.
* \param time Absolute time.
......@@ -113,6 +117,8 @@ void zone_events_schedule_at(struct zone *zone, zone_event_type_t type, time_t t
/*!
* \brief Schedule new zone event using relative time to current time.
*
* The function internally uses \ref zone_events_schedule_at.
*
* \param zone Zone to schedule new event for.
* \param type Type of event.
* \param dt Relative time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment