From: Vladimír Čunát Date: Tue, 23 Jan 2018 18:07:35 +0000 (+0100) Subject: nitpicks from review of !405: query-trace X-Git-Tag: v2.0.0~16^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f705c82a63bda7315930fd328886446e681c8b5d;p=thirdparty%2Fknot-resolver.git nitpicks from review of !405: query-trace The deckard change was probably unintentional, so I reverted that. The only real mistake I found was `sizeof(128)`, though the effect was just unnecessary reallocations. On the whole I really like it. Verbose logging might get slightly slower, due to increased amount of string allocation and copying, but it does seem worth it, at least until we can prove otherwise. I didn't look much into http module changes, etc. --- diff --git a/daemon/README.rst b/daemon/README.rst index 110173682..1b6108f89 100644 --- a/daemon/README.rst +++ b/daemon/README.rst @@ -277,10 +277,10 @@ to download cache from parent, to avoid cold-cache start. cache.size = 100*MB end -Events and services +Asynchronous events ^^^^^^^^^^^^^^^^^^^ -The Lua supports a concept called closures_, this is extremely useful for scripting actions upon various events, +Lua supports a concept called closures_, this is extremely useful for scripting actions upon various events, say for example - prune the cache within minute after loading, publish statistics each 5 minutes and so on. Here's an example of an anonymous function with :func:`event.recurrent()`: @@ -319,9 +319,8 @@ event loops or monitor open files and then fire a callback when an activity is d This allows you to build persistent services like HTTP servers or monitoring probes that cooperate well with the daemon internal operations. See :func:`event.socket()` -* File watchers -This is possible with :func:`worker.coroutine()` and cqueues_, see the cqueues documentation for more information. +File watchers are possible with :func:`worker.coroutine()` and cqueues_, see the cqueues documentation for more information. .. code-block:: lua @@ -440,7 +439,7 @@ Environment > user('root') Operation not permitted -.. function:: resolve(name, type[, class = kres.class.IN, options = 0, finish = nil]) +.. function:: resolve(name, type[, class = kres.class.IN, options = {}, finish = nil]) :param string name: Query name (e.g. 'com.') :param number type: Query type (e.g. ``kres.type.NS``) diff --git a/daemon/worker.c b/daemon/worker.c index a16018ee8..b814fe17f 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -2190,6 +2190,7 @@ int worker_process_tcp(struct worker_ctx *worker, uv_stream_t *handle, struct qr_task *worker_resolve_start(struct worker_ctx *worker, knot_pkt_t *query, struct kr_qflags options) { if (!worker || !query) { + assert(!EINVAL); return NULL; } diff --git a/lib/utils.c b/lib/utils.c index 4b320428f..5f61b10c8 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -834,7 +834,9 @@ char *kr_pkt_text(const knot_pkt_t *pkt) struct mempool *mp = mp_new(512); - static char *snames[] = {";; ANSWER SECTION",";; AUTHORITY SECTION",";; ADDITIONAL SECTION"}; + static const char * snames[] = { + ";; ANSWER SECTION", ";; AUTHORITY SECTION", ";; ADDITIONAL SECTION" + }; char rrtype[32]; char flags[32]; char qname[KNOT_DNAME_MAXLEN]; @@ -881,6 +883,7 @@ char *kr_pkt_text(const knot_pkt_t *pkt) for (knot_section_t i = KNOT_ANSWER; i <= KNOT_ADDITIONAL; ++i) { const knot_pktsection_t *sec = knot_pkt_section(pkt, i); if (sec->count == 0 || knot_pkt_rr(sec, 0)->type == KNOT_RRTYPE_OPT) { + /* OPT RRs are _supposed_ to be the last ^^, if they appear */ continue; } @@ -908,8 +911,8 @@ char *kr_rrset_text(const knot_rrset_t *rr) } /* Note: knot_rrset_txt_dump will double the size until the rrset fits */ - char *buf = malloc(128); - size_t bufsize = sizeof(128); + size_t bufsize = 128; + char *buf = malloc(bufsize); int ret = knot_rrset_txt_dump(rr, &buf, &bufsize, &KNOT_DUMP_STYLE_DEFAULT); if (ret < 0) { free(buf); @@ -922,4 +925,4 @@ char *kr_rrset_text(const knot_rrset_t *rr) uint64_t kr_now() { return uv_now(uv_default_loop()); -} \ No newline at end of file +} diff --git a/tests/deckard b/tests/deckard index 387e8845a..0a8445786 160000 --- a/tests/deckard +++ b/tests/deckard @@ -1 +1 @@ -Subproject commit 387e8845a45a7bab6ab1c8e5be55a8d88d0315ae +Subproject commit 0a844578608bb0c944880082bcbfce96453dfa98