From: Marek VavruĊĦa Date: Mon, 8 Dec 2014 13:32:35 +0000 (+0100) Subject: stats: queries are counted by the iterator, cleanup X-Git-Tag: v1.0.0-beta1~400 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=655615fa7f66561c468d6daef3fa46216aeb0500;p=thirdparty%2Fknot-resolver.git stats: queries are counted by the iterator, cleanup --- diff --git a/lib/layer/stats.c b/lib/layer/stats.c index 6da50ebf7..ac57615ea 100644 --- a/lib/layer/stats.c +++ b/lib/layer/stats.c @@ -39,7 +39,7 @@ static void update_ns_preference_list(struct kr_ns *cur) /* 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; @@ -86,8 +86,6 @@ static int query(knot_layer_t *ctx, knot_pkt_t *pkt) struct kr_layer_param *param = ctx->data; struct kr_result *result = param->result; - result->nr_queries += 1; - /* Store stats. */ gettimeofday(&result->t_start, NULL); @@ -114,17 +112,10 @@ static int answer(knot_layer_t *ctx, knot_pkt_t *pkt) #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;