+static int handle_request_pending(listen_socket_t *sock, /* {{{ */
+ char *buffer, size_t buffer_size)
+{
+ int status;
+ char *file, file_tmp[PATH_MAX];
+ cache_item_t *ci;
+
+ status = buffer_get_field(&buffer, &buffer_size, &file);
+ if (status != 0)
+ return send_response(sock, RESP_ERR,
+ "Usage: PENDING <filename>\n");
+
+ status = has_privilege(sock, PRIV_HIGH);
+ if (status <= 0)
+ return status;
+
+ get_abs_path(&file, file_tmp);
+
+ pthread_mutex_lock(&cache_lock);
+ ci = g_tree_lookup(cache_tree, file);
+ if (ci == NULL)
+ {
+ pthread_mutex_unlock(&cache_lock);
+ return send_response(sock, RESP_ERR, "%s\n", rrd_strerror(ENOENT));
+ }
+
+ for (int i=0; i < ci->values_num; i++)
+ add_response_info(sock, "%s\n", ci->values[i]);
+
+ pthread_mutex_unlock(&cache_lock);
+ return send_response(sock, RESP_OK, "updates pending\n");
+} /* }}} static int handle_request_pending */
+
+static int handle_request_forget(listen_socket_t *sock, /* {{{ */
+ char *buffer, size_t buffer_size)
+{
+ int status;
+ gboolean found;
+ char *file, file_tmp[PATH_MAX];
+
+ status = buffer_get_field(&buffer, &buffer_size, &file);
+ if (status != 0)
+ return send_response(sock, RESP_ERR,
+ "Usage: FORGET <filename>\n");
+
+ status = has_privilege(sock, PRIV_HIGH);
+ if (status <= 0)
+ return status;
+
+ get_abs_path(&file, file_tmp);
+ if (!check_file_access(file, sock)) return 0;
+
+ pthread_mutex_lock(&cache_lock);
+ found = g_tree_remove(cache_tree, file);
+ pthread_mutex_unlock(&cache_lock);
+
+ if (found == TRUE)
+ {
+ if (sock != NULL)
+ journal_write("forget", file);
+
+ return send_response(sock, RESP_OK, "Gone!\n");
+ }
+ else
+ return send_response(sock, RESP_ERR, "%s\n", rrd_strerror(ENOENT));
+
+ /* NOTREACHED */
+ assert(1==0);
+} /* }}} static int handle_request_forget */
+
+static int handle_request_queue (listen_socket_t *sock) /* {{{ */
+{
+ cache_item_t *ci;
+
+ pthread_mutex_lock(&cache_lock);
+
+ ci = cache_queue_head;
+ while (ci != NULL)
+ {
+ add_response_info(sock, "%d %s\n", ci->values_num, ci->file);
+ ci = ci->next;
+ }
+
+ pthread_mutex_unlock(&cache_lock);
+
+ return send_response(sock, RESP_OK, "in queue.\n");
+} /* }}} int handle_request_queue */
+