summaryrefslogtreecommitdiffstats
path: root/include/bmon/defs.h.in
diff options
context:
space:
mode:
authorBaptiste Jonglez <git@bitsofnetworks.org>2016-09-05 22:02:40 +0200
committerBaptiste Jonglez <git@bitsofnetworks.org>2016-11-12 19:29:39 +0100
commita3d894000b7243e4bfd54f99de3bee8154827897 (patch)
treecb8870c2922315e1491763303ed084337ecc2020 /include/bmon/defs.h.in
parent8b2638c349f780a0a66f6b4ef2430747d97bf24b (diff)
Use a monotonic clock instead of a realtime clock
Using a realtime clock is a bad idea: it is affected by any kind of time change, which can happen when the administrator modifies the system time, or more simply when a laptop suspends to RAM and then wakes up from sleep. With the current approach of using a realtime clock: - if the system time jumps forward (e.g. when resuming after a suspend-to-RAM), bmon would take 100% CPU and display random graph data extremely fast, until it "catches up" with the new time. - if the system time jumps backwards, bmon would freeze until *time* "catches up" to the point it was before. bmon then (incorrectly) displays a spike in the graph, because lots of packets have been sent/received since the last update. Instead of using gettimeofday(), switch to clock_gettime() with CLOCK_MONOTONIC on systems that support it. OS X does not provide clock_gettime(), so this commit also adds a Mach-specific implementation. This change has been tested on Linux 4.1 with glibc and musl, and on FreeBSD 10.0-RELEASE-p12.
Diffstat (limited to 'include/bmon/defs.h.in')
-rw-r--r--include/bmon/defs.h.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/bmon/defs.h.in b/include/bmon/defs.h.in
index d176c30..92b72eb 100644
--- a/include/bmon/defs.h.in
+++ b/include/bmon/defs.h.in
@@ -9,6 +9,9 @@
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
/* have curses */
#undef HAVE_CURSES
@@ -39,15 +42,15 @@
/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
+/* Define to 1 if you have the `rt' library (-lrt). */
+#undef HAVE_LIBRT
+
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H