]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add support for query timeouts
authorBrian De Wolf <bldewolf@csupomona.edu>
Thu, 12 Jan 2012 07:53:28 +0000 (08:53 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 12 Jan 2012 07:53:28 +0000 (08:53 +0100)
Due to internal MySQL retries, the actual timeout is 3x
the configured value.

src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c

index 85e3e76042f69e82b0027d9f52ab0ac0e32b6c72..17f0262a81fe4db72835226a445504a013f31117 100644 (file)
@@ -66,6 +66,7 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 {
        rlm_sql_mysql_sock *mysql_sock;
        unsigned long sql_flags;
+       unsigned int timeout = config->query_timeout;
 
        if (!sqlsocket->conn) {
                sqlsocket->conn = (rlm_sql_mysql_sock *)rad_malloc(sizeof(rlm_sql_mysql_sock));
@@ -81,6 +82,15 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config)
 
        mysql_init(&(mysql_sock->conn));
        mysql_options(&(mysql_sock->conn), MYSQL_READ_DEFAULT_GROUP, "freeradius");
+
+#if (MYSQL_VERSION_ID >= 50000)
+       if(timeout) {
+               mysql_options(&(mysql_sock->conn), MYSQL_OPT_CONNECT_TIMEOUT, &timeout);
+               mysql_options(&(mysql_sock->conn), MYSQL_OPT_READ_TIMEOUT, &timeout);
+               mysql_options(&(mysql_sock->conn), MYSQL_OPT_WRITE_TIMEOUT, &timeout);
+       }
+#endif
+
 #if (MYSQL_VERSION_ID >= 40100)
        sql_flags = CLIENT_MULTI_RESULTS | CLIENT_FOUND_ROWS;
 #else