-/* if sock==NULL, we are in journal replay mode */
-static int handle_request (listen_socket_t *sock, /* {{{ */
- time_t now,
- char *buffer, size_t buffer_size)
-{
- char *buffer_ptr;
- char *command;
- int status;
-
- assert (buffer[buffer_size - 1] == '\0');
-
- buffer_ptr = buffer;
- command = NULL;
- status = buffer_get_field (&buffer_ptr, &buffer_size, &command);
- if (status != 0)
- {
- RRDD_LOG (LOG_INFO, "handle_request: Unable parse command.");
- return (-1);
- }
-
- if (sock != NULL && sock->batch_start)
- sock->batch_cmd++;
-
- if (strcasecmp (command, "update") == 0)
- return (handle_request_update (sock, now, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "wrote") == 0 && sock == NULL)
- {
- /* this is only valid in replay mode */
- return (handle_request_wrote (buffer_ptr, now));
- }
- else if (strcasecmp (command, "flush") == 0)
- return (handle_request_flush (sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "flushall") == 0)
- return (handle_request_flushall(sock));
- else if (strcasecmp (command, "pending") == 0)
- return (handle_request_pending(sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "forget") == 0)
- return (handle_request_forget(sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "queue") == 0)
- return (handle_request_queue(sock));
- else if (strcasecmp (command, "stats") == 0)
- return (handle_request_stats (sock));
- else if (strcasecmp (command, "help") == 0)
- return (handle_request_help (sock, buffer_ptr, buffer_size));
- else if (strcasecmp (command, "batch") == 0 && sock != NULL)
- return batch_start(sock);
- else if (strcasecmp (command, ".") == 0 && sock != NULL && sock->batch_start)
- return batch_done(sock);
- else if (strcasecmp (command, "quit") == 0)
- return -1;
- else
- return send_response(sock, RESP_ERR, "Unknown command: %s\n", command);
-
- /* NOTREACHED */
- assert(1==0);
-} /* }}} int handle_request */
-
-/* MUST NOT hold journal_lock before calling this */
-static void journal_rotate(void) /* {{{ */