Commit 1f393e76 authored by Jan Kadlec's avatar Jan Kadlec

Another partial changes.

parent ac8efd41
......@@ -155,6 +155,57 @@ int knot_changeset_add_rr(knot_changeset_t *chgs, knot_rrset_t *rr,
}
}
int knot_changes_add_rrset(knot_changes_t *ch, knot_rrset_t *rrset,
knot_changes_part_t part)
{
if (ch == NULL || rrset == NULL) {
return KNOT_EINVAL;
}
knot_rr_node_t *rr_node =
ch->mem_ctx.alloc(ch->mem_ctx.ctx, sizeof(knot_rr_node_t));
if (rr_node == NULL) {
// This will not happen with mp_alloc, but allocator can change
ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
rr_node->rr = rrset;
if (part == KNOT_CHANGES_NEW) {
add_tail(&ch->new_rrsets, (node *)rr_node);
} else {
assert(part == KNOT_CHANGES_OLD);
add_tail(&ch->old_rrsets, (node *)rr_node);
}
return KNOT_EOK;
}
int knot_changes_add_node(knot_changes_t *ch, knot_node_t *kn_node,
knot_changes_part_t part)
{
if (ch == NULL || kn_node == NULL) {
return KNOT_EINVAL;
}
// Using the same allocator for node and rr's, sizes are equal.
knot_node_list_t *list_node =
ch->mem_ctx.alloc(ch->mem_ctx.ctx, sizeof(knot_node_list_t));
if (list_node == NULL) {
// This will not happen with mp_alloc, but allocator can change
ERR_ALLOC_FAILED;
return KNOT_ENOMEM;
}
list_node->node = kn_node;
if (part == KNOT_CHANGES_NORMAL_NODE) {
add_tail(&ch->old_nodes, (node *)list_node);
} else {
assert(part == KNOT_CHANGES_NSEC3_NODE);
add_tail(&ch->old_nsec3, (node *)list_node);
}
}
/*----------------------------------------------------------------------------*/
void knot_changeset_store_soa(knot_rrset_t **chg_soa,
......@@ -226,6 +277,14 @@ static void knot_free_changeset(knot_changeset_t *changeset)
free(changeset->data);
}
void knot_changes_free(knot_changes_t **changes)
{
// Destroy mempool's data
mp_delete((struct mempool *)((*changes)->mem_ctx.ctx));
free(*changes);
*changes = NULL;
}
/*----------------------------------------------------------------------------*/
void knot_free_changesets(knot_changesets_t **changesets)
......
......@@ -61,12 +61,18 @@ typedef struct knot_changeset {
/*----------------------------------------------------------------------------*/
/*! \brief Wrapper for oh-so-great BIRD lists. */
/*! \brief Wrapper for oh-so-great BIRD lists. Storing: RRSet. */
typedef struct knot_rr_node {
node n; /*!< List node. */
knot_rrset_t *rr; /*!< Actual usable data. */
} knot_rr_node_t;
/*! \brief Wrapper for oh-so-great BIRD lists. Storing: Node. */
typedef struct knot_node_list {
node n; /*!< List node. */
knot_node_t *node; /*!< Actual usable data. */
} knot_node_list_t;
/*! \brief Partial changes done to zones - used for update/transfer rollback. */
typedef struct {
/*!
......@@ -99,7 +105,7 @@ typedef struct {
typedef struct {
mm_ctx_t mem_ctx; /*!< Memory context - pool allocator. */
list sets; /*!< List of changesets. */
size_t count; /*!< Changeset coung. */
size_t count; /*!< Changeset count. */
knot_rrset_t *first_soa; /*!< First received SOA. */
uint32_t flags; /*!< DDNS / IXFR flags. */
knot_changes_t *changes; /*!< Partial changes. */
......@@ -114,7 +120,9 @@ typedef enum {
typedef enum {
KNOT_CHANGES_OLD,
KNOT_CHANGES_NEW
KNOT_CHANGES_NEW,
KNOT_CHANGES_NORMAL_NODE,
KNOT_CHANGES_NSEC3_NODE
} knot_changes_part_t;
/*----------------------------------------------------------------------------*/
......@@ -150,12 +158,14 @@ int knot_changeset_is_empty(const knot_changeset_t *changeset);
void knot_free_changesets(knot_changesets_t **changesets);
int knot_changes_add_rr(knot_changes_t *ch, knot_rrset_t *rrset,
knot_changes_part_t part);
int knot_changes_add_rrset(knot_changes_t *ch, knot_rrset_t *rrset,
knot_changes_part_t part);
int knot_changes_add_node(knot_changes_t *ch, knot_node_t *kn_node,
knot_changes_part_t part);
void knot_changes_free(knot_changes_t **changes);
#endif /* _KNOT_CHANGESETS_H_ */
/*! @} */
This diff is collapsed.
......@@ -196,7 +196,7 @@ int xfrin_switch_zone(knot_zone_t *zone,
knot_zone_contents_t *new_contents,
int deep_free);
void xfrin_cleanup_successful_update(knot_changes_t **changes);
void xfrin_cleanup_successful_update(knot_changes_t *changes);
void xfrin_rollback_update(knot_zone_contents_t *old_contents,
knot_zone_contents_t **new_contents,
......
......@@ -1036,8 +1036,6 @@ int knot_zone_diff_create_changesets(const knot_zone_contents_t *z1,
return ret;
}
(*changesets)->count = 1;
dbg_zonediff("Changesets created successfully!\n");
dbg_zonediff_detail("Changeset dump:\n");
dbg_zonediff_exec_detail(
......
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