diff --git a/src/knot/events/handlers/flush.c b/src/knot/events/handlers/flush.c index a15caf7cb51a0403ba67da5df0f9dd4af9e9695f..227205daacd8ab031db377af1123c47d74f38660 100644 --- a/src/knot/events/handlers/flush.c +++ b/src/knot/events/handlers/flush.c @@ -34,14 +34,5 @@ int event_flush(conf_t *conf, zone_t *zone) return ret; } - zone->timers.last_flush = time(NULL); - - conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name); - int64_t sync_timeout = conf_int(&val); - if (sync_timeout > 0) { - time_t next_flush = zone->timers.last_flush + sync_timeout; - zone_events_schedule_at(zone, ZONE_EVENT_FLUSH, next_flush); - } - return KNOT_EOK; } diff --git a/src/knot/zone/zone.c b/src/knot/zone/zone.c index ece749f3d90134b76064f6a542c7da4f87ee7b24..a84c60cf1b4314b97be991424a8431b6056f451f 100644 --- a/src/knot/zone/zone.c +++ b/src/knot/zone/zone.c @@ -139,7 +139,17 @@ static int flush_journal(conf_t *conf, zone_t *zone) /* Trim extra heap. */ mem_trim(); - return ret; + /* Plan next journal flush after proper period. */ + zone->timers.last_flush = time(NULL); + conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name); + int64_t sync_timeout = conf_int(&val); + if (sync_timeout > 0) { + time_t next_flush = zone->timers.last_flush + sync_timeout; + zone_events_schedule_at(zone, ZONE_EVENT_FLUSH, 0, + ZONE_EVENT_FLUSH, next_flush); + } + + return KNOT_EOK; } zone_t* zone_new(const knot_dname_t *name) @@ -271,19 +281,9 @@ int zone_changes_store(conf_t *conf, zone_t *zone, list_t *chgs) ret = journal_store_changesets(zone->journal, chgs); if (ret == KNOT_EBUSY) { log_zone_notice(zone->name, "journal is full, flushing"); - - /* - * TODO: Check where zone_flush_journal is used beyond - * event_flush(). zone->timers.last flush needs to be - * updated and flush event rescheduled. - * - * The code bellow does only half of it. - */ - /* Transaction rolled back, journal released, we may flush. */ ret = flush_journal(conf, zone); if (ret == KNOT_EOK) { - zone->timers.last_flush = time(NULL); ret = journal_store_changesets(zone->journal, chgs); } }