diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2020-08-23 11:40:32 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2020-08-23 16:18:20 +0100 |
commit | afade5fc02622ab0f6c545c723eed0eabaa75284 (patch) | |
tree | 5a9a7a8c66b21fb180d802e87f06e2f79488b58d /src | |
parent | e0ae68c8ee6788508da4989ee0d6fcbaf40c7b97 (diff) |
Debug: minor updates
Diffstat (limited to 'src')
-rw-r--r-- | src/src/debug.c | 31 | ||||
-rw-r--r-- | src/src/dns.c | 7 | ||||
-rw-r--r-- | src/src/functions.h | 2 | ||||
-rw-r--r-- | src/src/globals.h | 1 | ||||
-rw-r--r-- | src/src/host.c | 2 | ||||
-rw-r--r-- | src/src/macros.h | 2 | ||||
-rw-r--r-- | src/src/spool_in.c | 6 |
7 files changed, 27 insertions, 24 deletions
diff --git a/src/src/debug.c b/src/src/debug.c index 6d6132e39..90c48dde4 100644 --- a/src/src/debug.c +++ b/src/src/debug.c @@ -30,7 +30,15 @@ const uschar * rc_names[] = { /* Mostly for debug output */ [UNEXPECTED] = US"UNEXPECTED", [CANCELLED] = US"CANCELLED", [FAIL_SEND] = US"FAIL_SEND", - [FAIL_DROP] = US"FAIL_DROP" + [FAIL_DROP] = US"FAIL_DROP", +}; + +const uschar * dns_rc_names[] = { + [DNS_SUCCEED] = US"DNS_SUCCEED", + [DNS_NOMATCH] = US"DNS_NOMATCH", + [DNS_NODATA] = US"DNS_NODATA", + [DNS_AGAIN] = US"DNS_AGAIN", + [DNS_FAIL] = US"DNS_FAIL", }; @@ -43,8 +51,8 @@ hold the line-drawing characters that need to be printed on every line as it moves down the page. This function is used only in debugging circumstances. The output is done via debug_printf(). */ -#define tree_printlinesize 132 /* line size for printing */ -static uschar tree_printline[tree_printlinesize]; +#define TREE_PRINTLINESIZE 132 /* line size for printing */ +static uschar tree_printline[TREE_PRINTLINESIZE]; /* Internal recursive subroutine. @@ -57,12 +65,12 @@ Returns: nothing */ static void -tree_printsub(tree_node *p, int pos, int barswitch) +tree_printsub(tree_node * p, int pos, int barswitch) { if (p->right) tree_printsub(p->right, pos+2, 1); -for (int i = 0; i <= pos-1; i++) debug_printf("%c", tree_printline[i]); -debug_printf("-->%s [%d]\n", p->name, p->balance); -tree_printline[pos] = barswitch? '|' : ' '; +for (int i = 0; i <= pos-1; i++) debug_printf_indent(" %c", tree_printline[i]); +debug_printf_indent(" -->%s [%d]\n", p->name, p->balance); +tree_printline[pos] = barswitch ? '|' : ' '; if (p->left) { tree_printline[pos+2] = '|'; @@ -73,11 +81,12 @@ if (p->left) /* The external function, with just a tree node argument. */ void -debug_print_tree(tree_node *p) +debug_print_tree(const char * title, tree_node * p) { -for (int i = 0; i < tree_printlinesize; i++) tree_printline[i] = ' '; -if (!p) debug_printf("Empty Tree\n"); else tree_printsub(p, 0, 0); -debug_printf("---- End of tree ----\n"); +debug_printf_indent("%s:\n", title); +for (int i = 0; i < TREE_PRINTLINESIZE; i++) tree_printline[i] = ' '; +if (!p) debug_printf_indent(" Empty Tree\n"); else tree_printsub(p, 0, 0); +debug_printf_indent("---- End of tree ----\n"); } diff --git a/src/src/dns.c b/src/src/dns.c index 98c44b9f2..a636f076d 100644 --- a/src/src/dns.c +++ b/src/src/dns.c @@ -671,13 +671,10 @@ e = previous->data.ptr; val = e->data.val; rc = e->expiry && e->expiry <= time(NULL) ? -1 : val; -DEBUG(D_dns) debug_printf("DNS lookup of %.255s-%s: %scached value %s%s\n", +DEBUG(D_dns) debug_printf("DNS lookup of %.255s (%s): %scached value %s%s\n", name, dns_text_type(type), rc == -1 ? "" : "using ", - val == DNS_NOMATCH ? "DNS_NOMATCH" : - val == DNS_NODATA ? "DNS_NODATA" : - val == DNS_AGAIN ? "DNS_AGAIN" : - val == DNS_FAIL ? "DNS_FAIL" : "??", + dns_rc_names[val], rc == -1 ? " past valid time" : ""); return rc; diff --git a/src/src/functions.h b/src/src/functions.h index e5cf7f140..e7f643110 100644 --- a/src/src/functions.h +++ b/src/src/functions.h @@ -182,7 +182,7 @@ extern void debug_print_argv(const uschar **); extern void debug_print_ids(uschar *); extern void debug_printf_indent(const char *, ...) PRINTF_FUNCTION(1,2); extern void debug_print_string(uschar *); -extern void debug_print_tree(tree_node *); +extern void debug_print_tree(const char *, tree_node *); extern void debug_vprintf(int, const char *, va_list); extern void debug_print_socket(int); diff --git a/src/src/globals.h b/src/src/globals.h index 962da137f..47b4b5226 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -544,6 +544,7 @@ extern int dns_dane_ok; /* Ok to use DANE when checking TLS authe extern int dns_retrans; /* Retransmission time setting */ extern int dns_retry; /* Number of retries */ extern int dns_dnssec_ok; /* When constructing DNS query, set DO flag */ +extern const uschar * dns_rc_names[]; /* Mostly for debug output */ extern uschar *dns_trust_aa; /* DNSSEC trust AA as AD */ extern int dns_use_edns0; /* Coerce EDNS0 support on/off in resolver. */ extern uschar *dnslist_domain; /* DNS (black) list domain */ diff --git a/src/src/host.c b/src/src/host.c index 99bbba7a3..7408286ec 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -3197,7 +3197,7 @@ BOOL sec; rc = dns_lookup_timerwrap(dnsa, buffer, T_TLSA, &fullname); sec = dns_is_secure(dnsa); DEBUG(D_transport) - debug_printf("TLSA lookup ret %d %sDNSSEC\n", rc, sec ? "" : "not "); + debug_printf("TLSA lookup ret %s %sDNSSEC\n", dns_rc_names[rc], sec ? "" : "not "); switch (rc) { diff --git a/src/src/macros.h b/src/src/macros.h index baac435ec..5c3fa06f6 100644 --- a/src/src/macros.h +++ b/src/src/macros.h @@ -313,7 +313,7 @@ Use rc_names[] for debug strings. */ #define DELIVER_MUA_FAILED 2 /* Failure when mua_wrapper is set */ #define DELIVER_NOT_ATTEMPTED 3 /* Not tried (no msg or is locked */ -/* Returns from DNS lookup functions. */ +/* Returns from DNS lookup functions. Use dns_rc_names[] for debug strings */ enum { DNS_SUCCEED, DNS_NOMATCH, DNS_NODATA, DNS_AGAIN, DNS_FAIL }; diff --git a/src/src/spool_in.c b/src/src/spool_in.c index 4b70780bc..a2d3b8914 100644 --- a/src/src/spool_in.c +++ b/src/src/spool_in.c @@ -727,11 +727,7 @@ if (Ustrncmp(big_buffer, "XX\n", 3) != 0 && goto SPOOL_FORMAT_ERROR; #ifndef COMPILE_UTILITY -DEBUG(D_deliver) - { - debug_printf("Non-recipients:\n"); - debug_print_tree(tree_nonrecipients); - } +DEBUG(D_deliver) debug_print_tree("Non-recipients", tree_nonrecipients); #endif /* COMPILE_UTILITY */ /* After reading the tree, the next line has not yet been read into the |