2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

[master] dig -u: microsecond time output

3513.	[func]		"dig -u" prints times in microseconds rather than
			milliseconds. [RT #32704]
This commit is contained in:
Evan Hunt
2013-03-04 12:09:28 -08:00
parent 9ffd0f0270
commit 19b037bcb9
2 changed files with 32 additions and 11 deletions

View File

@@ -1,3 +1,6 @@
3513. [func] "dig -u" prints times in microseconds rather than
milliseconds. [RT #32704]
3512. [func] "rndc validation check" reports the current status 3512. [func] "rndc validation check" reports the current status
of DNSSEC validation. [RT #21397] of DNSSEC validation. [RT #21397]

View File

@@ -67,7 +67,7 @@ static char domainopt[DNS_NAME_MAXTEXT];
static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE, static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE, ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE, multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
onesoa = ISC_FALSE, rrcomments = ISC_FALSE; onesoa = ISC_FALSE, rrcomments = ISC_FALSE, use_usec = ISC_FALSE;
static isc_uint32_t splitwidth = 0xffffffff; static isc_uint32_t splitwidth = 0xffffffff;
/*% opcode text */ /*% opcode text */
@@ -173,6 +173,7 @@ help(void) {
" -q name (specify query name)\n" " -q name (specify query name)\n"
" -t type (specify query type)\n" " -t type (specify query type)\n"
" -c class (specify query class)\n" " -c class (specify query class)\n"
" -u (display times in usec instead of msec)\n"
" -k keyfile (specify tsig key file)\n" " -k keyfile (specify tsig key file)\n"
" -y [hmac:]name:key (specify named base64 tsig key)\n" " -y [hmac:]name:key (specify named base64 tsig key)\n"
" -4 (use IPv4 query transport only)\n" " -4 (use IPv4 query transport only)\n"
@@ -254,7 +255,10 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
if (query->lookup->stats && !short_form) { if (query->lookup->stats && !short_form) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
printf(";; Query time: %ld msec\n", (long int)diff/1000); if (use_usec)
printf(";; Query time: %ld usec\n", (long) diff);
else
printf(";; Query time: %ld msec\n", (long) diff / 1000);
printf(";; SERVER: %s(%s)\n", fromtext, query->servname); printf(";; SERVER: %s(%s)\n", fromtext, query->servname);
time(&tnow); time(&tnow);
tmnow = *localtime(&tnow); tmnow = *localtime(&tnow);
@@ -280,12 +284,20 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
puts(""); puts("");
} else if (query->lookup->identify && !short_form) { } else if (query->lookup->identify && !short_form) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
if (use_usec)
printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes " printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
"from %s(%s) in %d ms\n\n", "from %s(%s) in %ld us\n\n",
query->lookup->doing_xfr ? query->lookup->doing_xfr
query->byte_count : (isc_uint64_t)bytes, ? query->byte_count
fromtext, query->userarg, : (isc_uint64_t)bytes,
(int)diff/1000); fromtext, query->userarg, (long) diff);
else
printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
"from %s(%s) in %ld ms\n\n",
query->lookup->doing_xfr
? query->byte_count
: (isc_uint64_t)bytes,
fromtext, query->userarg, (long) diff / 1000);
} }
} }
@@ -325,7 +337,10 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
diff = isc_time_microdiff(&now, &query->time_sent); diff = isc_time_microdiff(&now, &query->time_sent);
ADD_STRING(buf, " from server "); ADD_STRING(buf, " from server ");
ADD_STRING(buf, query->servname); ADD_STRING(buf, query->servname);
snprintf(store, 19, " in %d ms.", (int)diff/1000); if (use_usec)
snprintf(store, 19, " in %ld us.", (long) diff);
else
snprintf(store, 19, " in %ld ms.", (long) diff / 1000);
ADD_STRING(buf, store); ADD_STRING(buf, store);
} }
ADD_STRING(buf, "\n"); ADD_STRING(buf, "\n");
@@ -1188,7 +1203,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
/*% /*%
* #ISC_TRUE returned if value was used * #ISC_TRUE returned if value was used
*/ */
static const char *single_dash_opts = "46dhimnv"; static const char *single_dash_opts = "46dhimnuv";
static const char *dash_opts = "46bcdfhikmnptvyx"; static const char *dash_opts = "46bcdfhikmnptvyx";
static isc_boolean_t static isc_boolean_t
dash_option(char *option, char *next, dig_lookup_t **lookup, dash_option(char *option, char *next, dig_lookup_t **lookup,
@@ -1211,7 +1226,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
while (strpbrk(option, single_dash_opts) == &option[0]) { while (strpbrk(option, single_dash_opts) == &option[0]) {
/* /*
* Since the -[46dhimnv] options do not take an argument, * Since the -[46dhimnuv] options do not take an argument,
* account for them (in any number and/or combination) * account for them (in any number and/or combination)
* if they appear as the first character(s) of a q-opt. * if they appear as the first character(s) of a q-opt.
*/ */
@@ -1260,6 +1275,9 @@ dash_option(char *option, char *next, dig_lookup_t **lookup,
case 'n': case 'n':
/* deprecated */ /* deprecated */
break; break;
case 'u':
use_usec = ISC_TRUE;
break;
case 'v': case 'v':
version(); version();
exit(0); exit(0);