From 55c6ef95caaf1b0c8a47858ffaa3709f94097ce9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 3 Jul 2008 10:48:17 +0200 Subject: [PATCH] src/rrd_daemon.c: Tell the connected party about invalid commands. --- src/rrd_daemon.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 1f961db..7e46dca 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #include @@ -857,23 +858,34 @@ static int handle_request (int fd) /* {{{ */ return (-1); } - if (strcmp (command, "update") == 0) + if (strcasecmp (command, "update") == 0) { return (handle_request_update (fd, buffer_ptr, buffer_size)); } - else if (strcmp (command, "flush") == 0) + else if (strcasecmp (command, "flush") == 0) { return (handle_request_flush (fd, buffer_ptr, buffer_size)); } - else if (strcmp (command, "stats") == 0) + else if (strcasecmp (command, "stats") == 0) { return (handle_request_stats (fd, buffer_ptr, buffer_size)); } else { - RRDD_LOG (LOG_INFO, "handle_request: unknown command: %s.", buffer); - return (-1); + char result[4096]; + + snprintf (result, sizeof (result), "-1 Unknown command: %s\n", command); + result[sizeof (result) - 1] = 0; + + status = write (fd, result, strlen (result)); + if (status < 0) + { + RRDD_LOG (LOG_ERR, "handle_request: write(2) failed."); + return (-1); + } } + + return (0); } /* }}} int handle_request */ static void *connection_thread_main (void *args /* {{{ */ -- 2.11.0