index 1fa4ba98c6888a726f8e921cce82f9d7e1d8900a..6b785392a1255311d5fae116a1bfb334186534db 100644 (file)
"(%zu byte%s left in buffer)", len, len == 1 ? "" : "s");
}
"(%zu byte%s left in buffer)", len, len == 1 ? "" : "s");
}
- sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection on fd=%i",
- conn->fd);
+ sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection %s", obj->name);
if (conn->fd >= 0)
close(conn->fd);
conn->fd = -1;
if (conn->fd >= 0)
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);
sdb_strbuf_destroy(conn->buf);
conn->buf = NULL;
sdb_strbuf_destroy(conn->errbuf);
const char *errmsg = "Authentication required";
sdb_connection_send(conn, CONNECTION_ERROR,
(uint32_t)strlen(errmsg), errmsg);
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;
}
return -1;
}
void
sdb_connection_close(sdb_conn_t *conn)
{
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 */
sdb_object_deref(SDB_OBJ(conn));
} /* sdb_connection_close */