From: Nick Porter Date: Fri, 6 Sep 2024 15:27:01 +0000 (+0100) Subject: Correct handling of MySQL connection openning immediately X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13edca1179a82282d6c650e5c473f413474d867f;p=thirdparty%2Ffreeradius-server.git Correct handling of MySQL connection openning immediately --- diff --git a/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c b/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c index 154a7b5729e..b86302bd17a 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c @@ -357,8 +357,7 @@ static connection_state_t _sql_connection_init(void **h, connection_t *conn, voi DEBUG2("Connected to database '%s' on %s, server version %s, protocol version %i", config->sql_db, mysql_get_host_info(c->sock), mysql_get_server_info(c->sock), mysql_get_proto_info(c->sock)); - connection_signal_connected(c->conn); - return CONNECTION_STATE_CONNECTING; + goto finish; } if (fr_event_fd_insert(c, NULL, c->conn->el, c->fd, @@ -368,12 +367,13 @@ static connection_state_t _sql_connection_init(void **h, connection_t *conn, voi DEBUG2("Connecting to database '%s' on %s:%d, fd %d", config->sql_db, config->sql_server, config->sql_port, c->fd); +finish: *h = c; if (config->connect_query) connection_add_watch_post(conn, CONNECTION_STATE_CONNECTED, _sql_connect_query_run, true, sql); - return CONNECTION_STATE_CONNECTING; + return c->status == 0 ? CONNECTION_STATE_CONNECTED : CONNECTION_STATE_CONNECTING; } static void _sql_connection_close(fr_event_list_t *el, void *h, UNUSED void *uctx)