+/*
+ * enqueue_cache_item:
+ * `cache_lock' must be acquired before calling this function!
+ */
+static int enqueue_cache_item (cache_item_t *ci) /* {{{ */
+{
+ RRDD_LOG (LOG_DEBUG, "handle_request_update: Adding %s to the update queue.",
+ ci->file);
+
+ if (ci == NULL)
+ return (-1);
+
+ if ((ci->flags & CI_FLAGS_IN_QUEUE) != 0)
+ return (-1);
+
+ assert (ci->next == NULL);
+
+ if (cache_queue_tail == NULL)
+ cache_queue_head = ci;
+ else
+ cache_queue_tail->next = ci;
+ cache_queue_tail = ci;
+
+ return (0);
+} /* }}} int enqueue_cache_item */
+
+/*
+ * tree_callback_flush:
+ * Called via `g_tree_foreach' in `queue_thread_main'. `cache_lock' is held
+ * while this is in progress.
+ */
+static gboolean tree_callback_flush (gpointer key, gpointer value, /* {{{ */
+ gpointer data)
+{
+ cache_item_t *ci;
+ time_t now;
+
+ ci = (cache_item_t *) value;
+ now = *((time_t *) data);
+
+ if (((now - ci->last_flush_time) >= config_write_interval)
+ && ((ci->flags & CI_FLAGS_IN_QUEUE) == 0))
+ enqueue_cache_item (ci);
+
+ return (TRUE);
+} /* }}} gboolean tree_callback_flush */
+