mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +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:
@@ -67,7 +67,7 @@ static char domainopt[DNS_NAME_MAXTEXT];
|
||||
static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
|
||||
ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = 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;
|
||||
|
||||
/*% opcode text */
|
||||
@@ -173,6 +173,7 @@ help(void) {
|
||||
" -q name (specify query name)\n"
|
||||
" -t type (specify query type)\n"
|
||||
" -c class (specify query class)\n"
|
||||
" -u (display times in usec instead of msec)\n"
|
||||
" -k keyfile (specify tsig key file)\n"
|
||||
" -y [hmac:]name:key (specify named base64 tsig key)\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) {
|
||||
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);
|
||||
time(&tnow);
|
||||
tmnow = *localtime(&tnow);
|
||||
@@ -280,12 +284,20 @@ received(int bytes, isc_sockaddr_t *from, dig_query_t *query) {
|
||||
puts("");
|
||||
} else if (query->lookup->identify && !short_form) {
|
||||
diff = isc_time_microdiff(&now, &query->time_sent);
|
||||
printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
|
||||
"from %s(%s) in %d ms\n\n",
|
||||
query->lookup->doing_xfr ?
|
||||
query->byte_count : (isc_uint64_t)bytes,
|
||||
fromtext, query->userarg,
|
||||
(int)diff/1000);
|
||||
if (use_usec)
|
||||
printf(";; Received %" ISC_PRINT_QUADFORMAT "u bytes "
|
||||
"from %s(%s) in %ld us\n\n",
|
||||
query->lookup->doing_xfr
|
||||
? query->byte_count
|
||||
: (isc_uint64_t)bytes,
|
||||
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);
|
||||
ADD_STRING(buf, " from server ");
|
||||
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, "\n");
|
||||
@@ -1188,7 +1203,7 @@ plus_option(char *option, isc_boolean_t is_batchfile,
|
||||
/*%
|
||||
* #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 isc_boolean_t
|
||||
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]) {
|
||||
/*
|
||||
* 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)
|
||||
* 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':
|
||||
/* deprecated */
|
||||
break;
|
||||
case 'u':
|
||||
use_usec = ISC_TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
version();
|
||||
exit(0);
|
||||
|
Reference in New Issue
Block a user