From: Alan T. DeKok Date: Thu, 12 Jan 2012 07:57:47 +0000 (+0100) Subject: Updates to last patch X-Git-Tag: release_3_0_0_beta0~405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=431d9820363dfec6511bc2f2836699d1d2c5beb0;p=thirdparty%2Ffreeradius-server.git Updates to last patch Fix compiler warnings. Code formatting. Divide external timeout by 3 to account for 3x retries hard-coded into MySQL --- diff --git a/src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c b/src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c index af466f1e99a..f2430c1a8eb 100644 --- a/src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c +++ b/src/modules/rlm_sql/drivers/rlm_sql_mysql/sql_mysql.c @@ -66,7 +66,6 @@ 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)); @@ -83,10 +82,22 @@ static int sql_init_socket(SQLSOCK *sqlsocket, SQL_CONFIG *config) 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); + if (config->query_timeout) { + unsigned int timeout = config->query_timeout; + + /* + * 3 retries are hard-coded into the MySQL library. + * We ensure that the REAL timeout is what the user + * set by accounting for that. + */ + if (timeout > 3) timeout /= 3; + + 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