@@ -120,26 +120,18 @@ ngs::Error_code Sql_data_context::init(const bool is_admin) {
120120}
121121
122122void Sql_data_context::report_error (int error, ...) {
123- if (attach ()) return ;
124-
125123 va_list args;
126124 va_start (args, error);
127125
128126 modules::Module_mysqlx::get_instance_services ()->m_runtime_error ->emit (
129127 m_authentication_code.error , MYF (0 ), args);
130128
131129 va_end (args);
132- detach ();
133130}
134131
135132void Sql_data_context::deinit () {
136133 if (m_mysql_session) {
137- srv_session_detach (m_mysql_session);
138-
139- log_debug (" sqlsession deinit: %p [%i]" , m_mysql_session,
140- srv_session_info_get_session_id (m_mysql_session));
141-
142- if (m_pre_authenticate_event_fired) {
134+ if (m_pre_authenticate_event_fired && !attach ()) {
143135 if (!m_authentication_code) {
144136 // In case of successfull login, connect event has been generated
145137 // earlier. Time for generating disconnect event.
@@ -191,6 +183,11 @@ void Sql_data_context::deinit() {
191183 m_pre_authenticate_event_fired = false ;
192184 m_authentication_code = ngs::Error_code ();
193185
186+ srv_session_detach (m_mysql_session);
187+
188+ log_debug (" sqlsession deinit: %p [%i]" , m_mysql_session,
189+ srv_session_info_get_session_id (m_mysql_session));
190+
194191 srv_session_close (m_mysql_session);
195192 m_mysql_session = nullptr ;
196193 }
0 commit comments