src/rrd_daemon.c: Tell the connected party about invalid commands.
authorFlorian Forster <octo@verplant.org>
Thu, 3 Jul 2008 08:48:17 +0000 (10:48 +0200)
committerFlorian Forster <octo@verplant.org>
Thu, 3 Jul 2008 08:48:17 +0000 (10:48 +0200)
src/rrd_daemon.c

index 1f961db..7e46dca 100644 (file)
@@ -66,6 +66,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
+#include <strings.h>
 #include <stdint.h>
 #include <inttypes.h>
 
@@ -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 /* {{{ */