+ clock_gettime(CLOCK_MONOTONIC, &t0); // FIXME: check errors
+ /* TODO: Cache expiration. i.e. use the TTL */
+ /* TODO: How to trigger TTL check? On select? Alarm signal? */
+ /* TODO: Set timeout on fifo_read_all based on diff of last time of
+ * fifo_read_all and desired time of next TTL check.
+ */
+ /* TODO: How long to wait on IO? Max TTL? */
+ fifo_read_all(cfg, buf);
+ if (cfg->output_to_x_root_window) {
+ if (XStoreName(display, DefaultRootWindow(display), buf) < 0)
+ fatal("XStoreName failed.\n");
+ XFlush(display);
+ } else {
+ puts(buf);
+ fflush(stdout);
+ }
+ clock_gettime(CLOCK_MONOTONIC, &t1); // FIXME: check errors
+ timespecsub(&t1, &t0, &td);
+ debug("td {tv_sec = %ld, tv_nsec = %ld}\n", td.tv_sec, td.tv_nsec);
+ if (timespeccmp(&td, &ti, <)) {
+ /* Pushback on data producers by refusing to read the
+ * pipe more frequently than the interval.
+ */
+ timespecsub(&ti, &td, &tc);
+ debug("snooze YES\n");
+ snooze(&tc);
+ } else {
+ debug("snooze NO\n");
+ }