Otherwise we can malfunction if the clock warps.
This depends on an unreleased adns feature, so the warning is
currently not actually printed.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Using non-monotonic clock, due to lack of adns_if_monotonic" >&5
-$as_echo "$as_me: WARNING: Using non-monotonic clock, due to lack of adns_if_monotonic" >&2;}
-
AC_CHECK_DECL([adns_if_monotonic],[
AC_DEFINE([USE_MONOTONIC],[1],[Use CLOCK_MONOTONIC and adns_if_monotonic])
],[
AC_CHECK_DECL([adns_if_monotonic],[
AC_DEFINE([USE_MONOTONIC],[1],[Use CLOCK_MONOTONIC and adns_if_monotonic])
],[
- AC_MSG_WARN([Using non-monotonic clock, due to lack of adns_if_monotonic])
+: dnl AC_MSG_WARN([Using non-monotonic clock, due to lack of adns_if_monotonic])
],[AC_INCLUDES_DEFAULT
#include <adns.h>
])
],[AC_INCLUDES_DEFAULT
#include <adns.h>
])
conf=dict_read_string(d,"config",False,"adns",loc);
adns_initflags iflags = 0;
conf=dict_read_string(d,"config",False,"adns",loc);
adns_initflags iflags = 0;
+#if USE_MONOTONIC
+ iflags |= adns_if_monotonic;
+#endif
if (conf) {
if (adns_init_strcfg(&st->ast, iflags, 0, conf)) {
if (conf) {
if (adns_init_strcfg(&st->ast, iflags, 0, conf)) {
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
int allocdfds=0, shortfall=0;
do {
int allocdfds=0, shortfall=0;
do {
+#if USE_MONOTONIC
+ struct timespec ts;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts)!=0) {
+ fatal_perror("main loop: clock_gettime(CLOCK_MONOTONIC,)");
+ }
+ tv_now_global.tv_sec = ts.tv_sec;
+ tv_now_global.tv_usec = ts.tv_nsec / 1000;
+#else /* !USE_MONOTONIC */
if (gettimeofday(&tv_now_global, NULL)!=0) {
fatal_perror("main loop: gettimeofday");
}
if (gettimeofday(&tv_now_global, NULL)!=0) {
fatal_perror("main loop: gettimeofday");
}
+#endif /* !USE_MONOTONIC */
now_global=((uint64_t)tv_now_global.tv_sec*(uint64_t)1000)+
((uint64_t)tv_now_global.tv_usec/(uint64_t)1000);
idx=0;
now_global=((uint64_t)tv_now_global.tv_sec*(uint64_t)1000)+
((uint64_t)tv_now_global.tv_usec/(uint64_t)1000);
idx=0;