Code

frontend: Treat CONNECTION_IDLE as an invalid command.
authorSebastian Harl <sh@tokkee.org>
Tue, 13 May 2014 21:33:52 +0000 (23:33 +0200)
committerSebastian Harl <sh@tokkee.org>
Tue, 13 May 2014 21:33:52 +0000 (23:33 +0200)
This is only meant for internal use; don't silently ignore it.

src/frontend/connection.c
t/unit/frontend/connection_test.c

index a146e29711c3aa1cc4de78f59672d43ee52091e6..923f000743db5f3694698ffbecdb9a0a033ec4b4 100644 (file)
@@ -376,6 +376,10 @@ command_init(sdb_conn_t *conn)
 
        len = 2 * sizeof(uint32_t);
        if (conn->cmd == CONNECTION_IDLE) {
+               const char *errmsg = "Invalid command 0";
+               sdb_strbuf_sprintf(conn->errbuf, errmsg);
+               sdb_connection_send(conn, CONNECTION_ERROR,
+                               (uint32_t)strlen(errmsg), errmsg);
                len += conn->cmd_len;
                conn->cmd_len = 0;
        }
index 125bb56fffb9eb2c3d8f6753fcf5e9fd4b50644f..da94f06ec3cfd1bf5b1391e7249b98dd6b9a0f20 100644 (file)
@@ -210,13 +210,13 @@ START_TEST(test_conn_setup)
                const char *err;
        } golden_data[] = {
                { UINT32_MAX,         NULL,       NULL },
-               { CONNECTION_IDLE,    "fakedata", NULL },
+               { CONNECTION_IDLE,    "fakedata", "Invalid command 0" },
                { CONNECTION_PING,    NULL,       "Authentication required" },
                { CONNECTION_STARTUP, "fakeuser", NULL },
                { CONNECTION_PING,    NULL,       NULL },
-               { CONNECTION_IDLE,    NULL,       NULL },
+               { CONNECTION_IDLE,    NULL,       "Invalid command 0" },
                { CONNECTION_PING,    "fakedata", NULL },
-               { CONNECTION_IDLE,    NULL,       NULL },
+               { CONNECTION_IDLE,    NULL,       "Invalid command 0" },
        };
 
        size_t i;