X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ffrontend%2Fconnection.c;h=6b785392a1255311d5fae116a1bfb334186534db;hb=8e7384947ee57bbbe58e210be4f6ec04ef8ff508;hp=b98987dd2e53b68ddf828e64c0bb67e61f01bba4;hpb=873f7603c5a213b0db58fa3c29d9e733f31366c8;p=sysdb.git diff --git a/src/frontend/connection.c b/src/frontend/connection.c index b98987d..6b78539 100644 --- a/src/frontend/connection.c +++ b/src/frontend/connection.c @@ -145,6 +145,10 @@ connection_destroy(sdb_object_t *obj) close(conn->fd); conn->fd = -1; + if (conn->username) + free(conn->username); + conn->username = NULL; + sdb_strbuf_destroy(conn->buf); conn->buf = NULL; sdb_strbuf_destroy(conn->errbuf); @@ -263,6 +267,10 @@ 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; } @@ -439,6 +447,14 @@ sdb_connection_accept(int fd) void sdb_connection_close(sdb_conn_t *conn) { + if (! conn) + return; + + /* close the connection even if someone else still references it */ + if (conn->fd >= 0) + close(conn->fd); + conn->fd = -1; + sdb_object_deref(SDB_OBJ(conn)); } /* sdb_connection_close */