summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-02-21 07:44:51 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-02-21 07:44:51 +0000
commite9526657fd44ce30ca23c3300b51ce25ee4bf72d (patch)
tree55a27976e2a5297dfc17207db6d9f661729f839c /usr.bin
parent5681478617903bd49639c707b53123d7a1644c09 (diff)
Read CLOCK_MONOTONIC when we need timestamps to compare and use
time(3) for the wall clock. prodding & OK jung
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/dig/dighost.c10
-rw-r--r--usr.bin/dig/host.c2
-rw-r--r--usr.bin/dig/lib/isc/log.c14
-rw-r--r--usr.bin/dig/lib/isc/timer.c10
-rw-r--r--usr.bin/dig/lib/isc/unix/app.c2
5 files changed, 19 insertions, 19 deletions
diff --git a/usr.bin/dig/dighost.c b/usr.bin/dig/dighost.c
index aa1fd187eb9..e0f237a2299 100644
--- a/usr.bin/dig/dighost.c
+++ b/usr.bin/dig/dighost.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dighost.c,v 1.12 2020/02/20 18:07:59 florian Exp $ */
+/* $Id: dighost.c,v 1.13 2020/02/21 07:44:50 florian Exp $ */
/*! \file
* \note
@@ -380,7 +380,7 @@ debug(const char *format, ...) {
if (debugging) {
fflush(stdout);
if (debugtiming) {
- clock_gettime(CLOCK_REALTIME, &t);
+ clock_gettime(CLOCK_MONOTONIC, &t);
fprintf(stderr, "%lld.%06ld: ", t.tv_sec, t.tv_nsec /
1000);
}
@@ -2704,7 +2704,7 @@ send_udp(dig_query_t *query) {
sendbuf = clone_buffer(&query->sendbuf);
ISC_LIST_ENQUEUE(query->sendlist, sendbuf, link);
debug("sending a request");
- clock_gettime(CLOCK_REALTIME, &query->time_sent);
+ clock_gettime(CLOCK_MONOTONIC, &query->time_sent);
INSIST(query->sock != NULL);
query->waiting_senddone = ISC_TRUE;
result = isc_socket_sendtov2(query->sock, &query->sendlist,
@@ -2920,7 +2920,7 @@ launch_next_query(dig_query_t *query, isc_boolean_t include_question) {
debug("recvcount=%d", recvcount);
if (!query->first_soa_rcvd) {
debug("sending a request in launch_next_query");
- clock_gettime(CLOCK_REALTIME, &query->time_sent);
+ clock_gettime(CLOCK_MONOTONIC, &query->time_sent);
query->waiting_senddone = ISC_TRUE;
result = isc_socket_sendv(query->sock, &query->sendlist,
global_task, send_done, query);
@@ -3290,7 +3290,7 @@ recv_done(isc_task_t *task, isc_event_t *event) {
INSIST(recvcount >= 0);
query = event->ev_arg;
- clock_gettime(CLOCK_REALTIME, &query->time_recv);
+ clock_gettime(CLOCK_MONOTONIC, &query->time_recv);
debug("lookup=%p, query=%p", query->lookup, query);
l = query->lookup;
diff --git a/usr.bin/dig/host.c b/usr.bin/dig/host.c
index 123a0ccf632..71a95ce9265 100644
--- a/usr.bin/dig/host.c
+++ b/usr.bin/dig/host.c
@@ -149,7 +149,7 @@ received(unsigned int bytes, isc_sockaddr_t *from, dig_query_t *query) {
if (!short_form) {
char fromtext[ISC_SOCKADDR_FORMATSIZE];
isc_sockaddr_format(from, fromtext, sizeof(fromtext));
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
diff = (int) isc_time_microdiff(&now, &query->time_sent);
printf("Received %u bytes from %s in %d ms\n",
bytes, fromtext, diff/1000);
diff --git a/usr.bin/dig/lib/isc/log.c b/usr.bin/dig/lib/isc/log.c
index 857c1f69a3a..9648fb35619 100644
--- a/usr.bin/dig/lib/isc/log.c
+++ b/usr.bin/dig/lib/isc/log.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: log.c,v 1.15 2020/02/18 18:11:27 florian Exp $ */
+/* $Id: log.c,v 1.16 2020/02/21 07:44:50 florian Exp $ */
/*! \file
* \author Principal Authors: DCL */
@@ -862,11 +862,10 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
if ((channel->flags & ISC_LOG_PRINTTIME) != 0 &&
time_string[0] == '\0') {
- struct timespec now;
-
- clock_gettime(CLOCK_REALTIME, &now);
+ time_t now;
+ now = time(NULL);
strftime(time_string, sizeof(time_string),
- "%d-%b-%Y %X", localtime(&now.tv_sec));
+ "%d-%b-%Y %X", localtime(&now));
}
if ((channel->flags & ISC_LOG_PRINTLEVEL) != 0 &&
@@ -906,7 +905,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
* which fall within the duplicate_interval
* range.
*/
- clock_gettime(CLOCK_REALTIME, &oldest);
+ clock_gettime(CLOCK_MONOTONIC, &oldest);
timespecsub(&oldest, &interval, &oldest);
message = ISC_LIST_HEAD(lctx->messages);
@@ -969,7 +968,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
strlcpy(message->text, lctx->buffer,
size);
- clock_gettime(CLOCK_REALTIME, &message->time);
+ clock_gettime(CLOCK_MONOTONIC,
+ &message->time);
ISC_LINK_INIT(message, link);
ISC_LIST_APPEND(lctx->messages,
diff --git a/usr.bin/dig/lib/isc/timer.c b/usr.bin/dig/lib/isc/timer.c
index b99db8147eb..6dbbf1d2cb1 100644
--- a/usr.bin/dig/lib/isc/timer.c
+++ b/usr.bin/dig/lib/isc/timer.c
@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: timer.c,v 1.19 2020/02/18 18:11:27 florian Exp $ */
+/* $Id: timer.c,v 1.20 2020/02/21 07:44:50 florian Exp $ */
/*! \file */
@@ -188,7 +188,7 @@ isc_timer_create(isc_timermgr_t *manager0, const struct timespec *interval,
/*
* Get current time.
*/
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timer = malloc(sizeof(*timer));
if (timer == NULL)
@@ -254,7 +254,7 @@ isc_timer_reset(isc_timer_t *timer, const struct timespec *interval,
/*
* Get current time.
*/
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
if (purge)
(void)isc_task_purgerange(timer->task,
@@ -283,7 +283,7 @@ isc_timer_touch(isc_timer_t *timer) {
*/
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
timespecadd(&now, &timer->interval, &timer->idle);
}
@@ -501,7 +501,7 @@ isc_timermgr_dispatch(isc_timermgr_t *manager0) {
manager = timermgr;
if (manager == NULL)
return;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
dispatch(manager, &now);
}
diff --git a/usr.bin/dig/lib/isc/unix/app.c b/usr.bin/dig/lib/isc/unix/app.c
index 95b5e1ab81a..2fe62279087 100644
--- a/usr.bin/dig/lib/isc/unix/app.c
+++ b/usr.bin/dig/lib/isc/unix/app.c
@@ -164,7 +164,7 @@ evloop(isc_appctx_t *ctx) {
else {
uint64_t us;
- clock_gettime(CLOCK_REALTIME, &now);
+ clock_gettime(CLOCK_MONOTONIC, &now);
us = isc_time_microdiff(&when, &now);
if (us == 0)
call_timer_dispatch = ISC_TRUE;