Commit 288cca5b authored by Vladimír Čunát's avatar Vladimír Čunát

kr_rplan_pop(): avoid reordering kr_rplan::pending

- It's not ideal, but this will need significant overhaul anyway when
  "parallel queries" get implemented.
- I didn't put this into array.h, as we don't seem likely to need it
  anywhere else and implementation in macros would be ugly.
- It's unclear whether this "bug" could cause anything in practice.
parent 72e13048
......@@ -253,7 +253,12 @@ int kr_rplan_pop(struct kr_rplan *rplan, struct kr_query *qry)
/* Find the query, it will likely be on top */
for (size_t i = rplan->pending.len; i > 0; i--) {
if (rplan->[i - 1] == qry) {
array_del(rplan->pending, i - 1);
/* Delete i-1 element by *sliding* the rest,
* contrary to array_del() */
for (size_t j = i; j < rplan->pending.len; ++j)
rplan->[j - 1] = rplan->[j];
array_push(rplan->resolved, qry);
......@@ -123,7 +123,10 @@ typedef array_t(struct kr_query *) kr_qarray_t;
* It also keeps a notion of current zone cut.
struct kr_rplan {
kr_qarray_t pending; /**< List of pending queries. */
kr_qarray_t pending; /**< List of pending queries.
Beware: order is significant ATM,
as the last is the next one to solve,
and they may be inter-dependent. */
kr_qarray_t resolved; /**< List of resolved queries. */
struct kr_request *request; /**< Parent resolution request. */
knot_mm_t *pool; /**< Temporary memory pool. */
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