From b6899cbf72d3f1596fc466b1aa365cea83e55410 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 12 Feb 2015 17:03:38 -0600 Subject: add a g_message() when updating due to anything that's not a periodic timer --- src/clock-live.cpp | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/clock-live.cpp') diff --git a/src/clock-live.cpp b/src/clock-live.cpp index b91fc62..988d47f 100644 --- a/src/clock-live.cpp +++ b/src/clock-live.cpp @@ -117,25 +117,28 @@ private: g_error("timerfd_settime failed: %s", g_strerror(errno)); } - static gboolean on_timerfd_cond (gint fd, GIOCondition cond G_GNUC_UNUSED, gpointer gself) + static gboolean on_timerfd_cond (gint fd, GIOCondition cond, gpointer gself) { - // let's see what triggered this event auto self = static_cast(gself); + + int n_bytes = 0; uint64_t n_interrupts = 0; - auto s = read(fd, &n_interrupts, sizeof(uint64_t)); - - // make a debug log of what just happened - auto now = g_date_time_new_now(self->m_gtimezone); - auto now_str = g_date_time_format(now, "%F %T"); - g_debug("%s at %s (%f), read %zd bytes to get n_interrupts %zu", - G_STRFUNC, now_str, g_date_time_get_seconds(now), - s, n_interrupts); - g_free(now_str); - g_date_time_unref(now); + if (cond & G_IO_IN) + n_bytes = read(fd, &n_interrupts, sizeof(uint64_t)); - // if we weren't triggered because of a timeout, then it may have - // happened due to time being set, so reset the timer - self->reset_timer(); + if ((n_interrupts==0) || (n_bytes!=sizeof(uint64_t))) + { + auto now = g_date_time_new_now(self->m_gtimezone); + auto now_str = g_date_time_format(now, "%F %T"); + g_message("%s triggered at %s.%06d by GIOCondition %d, read %zd bytes, found %zu interrupts", + G_STRFUNC, now_str, g_date_time_get_microsecond(now), + (int)cond, n_bytes, n_interrupts); + g_free(now_str); + g_date_time_unref(now); + + // reset the timer in case someone changed the system clock + self->reset_timer(); + } self->refresh(); return G_SOURCE_CONTINUE; -- cgit v1.2.3