aboutsummaryrefslogtreecommitdiff
path: root/src/clock-live.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-02-12 17:03:38 -0600
committerCharles Kerr <charles.kerr@canonical.com>2015-02-12 17:03:38 -0600
commitb6899cbf72d3f1596fc466b1aa365cea83e55410 (patch)
tree53d024089e6c3c80d887362661a7bdcff8aa83cc /src/clock-live.cpp
parentde6bc91f29122242fab6da7f5120f5bc8c64a1d6 (diff)
downloadayatana-indicator-datetime-b6899cbf72d3f1596fc466b1aa365cea83e55410.tar.gz
ayatana-indicator-datetime-b6899cbf72d3f1596fc466b1aa365cea83e55410.tar.bz2
ayatana-indicator-datetime-b6899cbf72d3f1596fc466b1aa365cea83e55410.zip
add a g_message() when updating due to anything that's not a periodic timer
Diffstat (limited to 'src/clock-live.cpp')
-rw-r--r--src/clock-live.cpp33
1 files changed, 18 insertions, 15 deletions
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<Impl*>(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;