]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Correct handling of MySQL connection openning immediately
authorNick Porter <nick@portercomputing.co.uk>
Fri, 6 Sep 2024 15:27:01 +0000 (16:27 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 12 Sep 2024 09:22:12 +0000 (10:22 +0100)
src/modules/rlm_sql/drivers/rlm_sql_mysql/rlm_sql_mysql.c

index 154a7b5729e59e871599a1a8586ba884e1f5bd66..b86302bd17a2ed37f5262cb194d172d263a2fc2c 100644 (file)
@@ -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)