SQLServer: Use m_client_id instead of client_id in callback

In the DatabaseConnection constructor, there's a deferred_invoke
callback that references the client_id. But depending on when the
callback occurs, the reference of the client_id can change. This created
a problem when connecting to SQLServer using the SQL utility because
depending on when the callback was invoked, the client_id could change.

m_client_id is set in the constructor and that reference will not change
depending on when the callback is invoked.
This commit is contained in:
Robert Stefanic 2021-08-21 14:03:44 -04:00 committed by Andreas Kling
parent 9a4c1c019a
commit e4f040147f
Notes: sideshowbarker 2024-07-18 05:23:30 +09:00

View File

@ -41,7 +41,7 @@ DatabaseConnection::DatabaseConnection(String database_name, int client_id)
deferred_invoke([&](Object&) {
m_database = SQL::Database::construct(String::formatted("/home/anon/sql/{}.db", m_database_name));
m_accept_statements = true;
auto client_connection = ClientConnection::client_connection_for(client_id);
auto client_connection = ClientConnection::client_connection_for(m_client_id);
if (client_connection)
client_connection->async_connected(m_connection_id);
else