Commit a6febb51 authored by Jan Kadlec's avatar Jan Kadlec

changeset: Fixed review remarks in ixfr.c

parent a23281e8
......@@ -48,7 +48,9 @@ struct ixfr_proc {
return ret; \
}
static int ixfr_put_chg_part(knot_pkt_t *pkt, struct ixfr_proc *ixfr, changeset_iter_t *itt)
/*! \brief Puts current RR into packet, stores state for retries. */
static int ixfr_put_chg_part(knot_pkt_t *pkt, struct ixfr_proc *ixfr,
changeset_iter_t *itt)
{
assert(pkt);
assert(ixfr);
......@@ -66,6 +68,12 @@ static int ixfr_put_chg_part(knot_pkt_t *pkt, struct ixfr_proc *ixfr, changeset_
return ret;
}
/*! \brief Tests if iteration has started. */
static bool iter_empty(struct ixfr_proc *ixfr)
{
return EMPTY_LIST(ixfr->cur.iters) && knot_rrset_empty(&ixfr->cur_rr);
}
/*!
* \brief Process single changeset.
* \note Keep in mind that this function must be able to resume processing,
......@@ -89,8 +97,11 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Put REMOVE RRSets. */
if (ixfr->state == IXFR_DEL) {
if (EMPTY_LIST(ixfr->cur.iters) && knot_rrset_empty(&ixfr->cur_rr)) {
changeset_iter_rem(&ixfr->cur, chgset, false);
if (iter_empty(ixfr)) {
ret = changeset_iter_rem(&ixfr->cur, chgset, false);
if (ret != KNOT_EOK) {
return ret;
}
}
ret = ixfr_put_chg_part(pkt, ixfr, &ixfr->cur);
if (ret != KNOT_EOK) {
......@@ -109,8 +120,11 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
/* Put Add RRSets. */
if (ixfr->state == IXFR_ADD) {
if (EMPTY_LIST(ixfr->cur.iters) && knot_rrset_empty(&ixfr->cur_rr)) {
if (iter_empty(ixfr)) {
changeset_iter_add(&ixfr->cur, chgset, false);
if (ret != KNOT_EOK) {
return ret;
}
}
ret = ixfr_put_chg_part(pkt, ixfr, &ixfr->cur);
if (ret != KNOT_EOK) {
......@@ -131,6 +145,7 @@ static int ixfr_process_changeset(knot_pkt_t *pkt, const void *item,
#undef IXFR_SAFE_PUT
/*! \brief Loads IXFRs from journal. */
static int ixfr_load_chsets(list_t *chgsets, const zone_t *zone,
const knot_rrset_t *their_soa)
{
......@@ -153,6 +168,7 @@ static int ixfr_load_chsets(list_t *chgsets, const zone_t *zone,
return ret;
}
/*! \brief Check IXFR query validity. */
static int ixfr_query_check(struct query_data *qdata)
{
/* Check if zone exists. */
......@@ -177,6 +193,7 @@ static int ixfr_query_check(struct query_data *qdata)
return NS_PROC_DONE;
}
/*! \brief Cleans up ixfr processing context. */
static void ixfr_answer_cleanup(struct query_data *qdata)
{
struct ixfr_proc *ixfr = (struct ixfr_proc *)qdata->ext;
......@@ -191,6 +208,7 @@ static void ixfr_answer_cleanup(struct query_data *qdata)
rcu_read_unlock();
}
/*! \brief Inits ixfr processing context. */
static int ixfr_answer_init(struct query_data *qdata)
{
/* Check IXFR query validity. */
......@@ -252,6 +270,7 @@ static int ixfr_answer_init(struct query_data *qdata)
return KNOT_EOK;
}
/*! \brief Sends response to SOA query. */
static int ixfr_answer_soa(knot_pkt_t *pkt, struct query_data *qdata)
{
dbg_ns("%s: answering IXFR/SOA\n", __func__);
......
/*!
* \file ixfr.h
*
* \author Marek Vavrusa <marek.vavrusa@nic.cz>
* \author Marek Vavrusa <marek.vavrusa@nic.cz> - IXFR/OUT
* \author Jan Kadlec <marek.vavrusa@nic.cz> - IXFR/IN
*
* \brief IXFR processing.
*
......
......@@ -65,7 +65,7 @@ typedef struct {
int changeset_init(changeset_t *ch, const knot_dname_t *apex);
/*!
* \brief Creates new changeset structure.
* \brief Creates new changeset structure and inits it.
*
* \param apex Zone apex DNAME.
*
......
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