/* O(n), walk the list (shouldn't be too large). */
/* TODO: cut on first swap? random swaps? */
- while (next->node.next != NULL) {
+ while (next && next->node.next != NULL) {
update_ns_preference(cur, next);
cur = next;
next = (struct kr_ns *)cur->node.next;
struct kr_layer_param *param = ctx->data;
struct kr_result *result = param->result;
- result->nr_queries += 1;
-
/* Store stats. */
gettimeofday(&result->t_start, NULL);
#ifndef NDEBUG
char ns_name[KNOT_DNAME_MAXLEN] = { '\0' };
- knot_dname_to_str(ns_name, ns->name, sizeof(ns_name) - 1);
- char pad[16];
- memset(pad, '-', sizeof(pad));
- int pad_len = list_size(&resolve->rplan.q) * 2;
- if (pad_len > sizeof(pad) - 1) {
- pad_len = sizeof(pad) - 1;
- }
- DEBUG_MSG("#%s %s ... RC=%d, AA=%d, RTT: %.02f msecs\n",
- pad, ns_name, knot_wire_get_rcode(pkt->wire),
- knot_wire_get_aa(pkt->wire) != 0,
- rtt);
+ knot_dname_to_str(ns_name, ns->name, sizeof(ns_name));
+ DEBUG_MSG("answer from '%s' RC=%d, AA=%d, RTT: %.02f msecs\n",
+ ns_name, knot_wire_get_rcode(pkt->wire),
+ knot_wire_get_aa(pkt->wire) != 0, rtt);
#endif
return ctx->state;