From 4c76dfa1f554725ebc143170087ed705f2858666 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 23 Apr 2014 23:08:19 +0200 Subject: [PATCH] frontend: Always reset the current command after handling it. That is, also reset it after an authentication error. --- src/frontend/connection.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/frontend/connection.c b/src/frontend/connection.c index 6b78539..b4f170b 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -267,10 +267,6 @@ command_handle(sdb_conn_t *conn) const char *errmsg = "Authentication required"; sdb_connection_send(conn, CONNECTION_ERROR, (uint32_t)strlen(errmsg), errmsg); - - /* remove the command from the buffer */ - if (conn->cmd_len) - sdb_strbuf_skip(conn->buf, 0, conn->cmd_len); return -1; } @@ -363,12 +359,6 @@ command_handle(sdb_conn_t *conn) sdb_connection_send(conn, CONNECTION_ERROR, (uint32_t)sdb_strbuf_len(conn->errbuf), sdb_strbuf_string(conn->errbuf)); - - /* remove the command from the buffer */ - if (conn->cmd_len) - sdb_strbuf_skip(conn->buf, 0, conn->cmd_len); - conn->cmd = CONNECTION_IDLE; - conn->cmd_len = 0; return status; } /* command_handle */ @@ -472,9 +462,16 @@ sdb_connection_read(sdb_conn_t *conn) && (sdb_strbuf_len(conn->buf) >= 2 * sizeof(int32_t))) command_init(conn); if ((conn->cmd != CONNECTION_IDLE) - && (sdb_strbuf_len(conn->buf) >= conn->cmd_len)) + && (sdb_strbuf_len(conn->buf) >= conn->cmd_len)) { command_handle(conn); + /* remove the command from the buffer */ + if (conn->cmd_len) + sdb_strbuf_skip(conn->buf, 0, conn->cmd_len); + conn->cmd = CONNECTION_IDLE; + conn->cmd_len = 0; + } + if (status <= 0) break; -- 2.30.2