Skip to content
Snippets Groups Projects
Commit 6f924651 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman
Browse files

zone: more (writing) support for zone-in-journal

parent e67fb21d
No related branches found
No related tags found
No related merge requests found
......@@ -332,6 +332,33 @@ int zone_in_journal_load(conf_t *conf, zone_t *zone, list_t *dst)
return ret;
}
int zone_in_journal_store(conf_t *conf, zone_t *zone, zone_contents_t *new_contents)
{
if (conf == NULL || zone == NULL || new_contents == NULL) {
return KNOT_EINVAL;
}
/* Check for disabled zonefile synchronization. */
conf_val_t val = conf_zone_get(conf, C_ZONEFILE_SYNC, zone->name);
if (conf_int(&val) >= 0) {
// for now we better flush the zonefile instead of zone-in-journal
// when the priority over zonefile and journal changes, replace this check
return KNOT_ENOTSUP;
}
if (journal_exists(zone->journal_db, zone->name)) {
// for now we refuse storing zone-in-journal into existing journal
// TODO maybe store the diff in such case as a normal changeset ?
return KNOT_EEXIST;
}
changeset_t *co_ch = changeset_from_contents(new_contents);
int ret = co_ch ? zone_change_store(conf, zone, co_ch) : KNOT_ENOMEM;
changeset_from_contents_free(co_ch);
return ret;
}
int zone_flush_journal(conf_t *conf, zone_t *zone)
{
if (conf == NULL || zone == NULL) {
......
......@@ -133,6 +133,7 @@ int zone_change_store(conf_t *conf, zone_t *zone, changeset_t *change);
int zone_changes_store(conf_t *conf, zone_t *zone, list_t *chgs);
int zone_changes_load(conf_t *conf, zone_t *zone, list_t *dst, uint32_t from);
int zone_in_journal_load(conf_t *conf, zone_t *zone, list_t *dst);
int zone_in_journal_store(conf_t *conf, zone_t *zone, zone_contents_t *new_contents);
/*! \brief Synchronize zone file with journal. */
int zone_flush_journal(conf_t *conf, zone_t *zone);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment