]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
nitpicks from review of !405: query-trace
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 23 Jan 2018 18:07:35 +0000 (19:07 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 23 Jan 2018 18:37:14 +0000 (19:37 +0100)
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.

daemon/README.rst
daemon/worker.c
lib/utils.c
tests/deckard

index 110173682c30a322e35feb99d106fb516dc0fa40..1b6108f89ed8207652f28ef74aae3ad6303f774a 100644 (file)
@@ -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``)
index a16018ee87ce4a6f647361887e773da52bd7645a..b814fe17f80248ca003e78abb625ae79d7e0f459 100644 (file)
@@ -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;
        }
 
index 4b320428f522f91d54648cb9a8f2261437227582..5f61b10c87fb1ce9d8a89360e15dcb3f65a8c355 100644 (file)
@@ -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
+}
index 387e8845a45a7bab6ab1c8e5be55a8d88d0315ae..0a844578608bb0c944880082bcbfce96453dfa98 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 387e8845a45a7bab6ab1c8e5be55a8d88d0315ae
+Subproject commit 0a844578608bb0c944880082bcbfce96453dfa98