Skip to content

Commit

Permalink
db_mysql: Drop usage of MYSQL_OPT_RECONNECT in 8.0.35+
Browse files Browse the repository at this point in the history
The auto-reconnect feature of libmysqlclient has been deprecated
starting with version 8.0.34 and is subject to future removal.
Moreover, OpenSIPS was explicitly disabling it anyway on startup, in
favour of the "max_db_queries" application-level query retrying loop.
  • Loading branch information
liviuchircu committed May 28, 2024
1 parent 03265f0 commit 39f056b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/db_mysql/my_con.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ int db_mysql_connect(struct my_con* ptr)
{
str *tls_domain_name;

my_bool reconnect = 0;
/* if connection already in use, close it first*/
if (ptr->init)
mysql_close(ptr->con);
Expand Down Expand Up @@ -95,11 +94,14 @@ int db_mysql_connect(struct my_con* ptr)
mysql_options(ptr->con, MYSQL_OPT_READ_TIMEOUT, (void *)&db_mysql_timeout_interval);
mysql_options(ptr->con, MYSQL_OPT_WRITE_TIMEOUT, (void *)&db_mysql_timeout_interval);

/* force no auto reconnection */
#if MYSQL_VERSION_ID >= 50013
mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &reconnect);
#else
/* explicitly disable auto-reconnect on older libraries (default: 0) */
#if MYSQL_VERSION_ID < 50013
ptr->con->reconnect = 0;
#elif MYSQL_VERSION_ID < 80034
{
my_bool reconnect = 0;
mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &reconnect);
}
#endif

if (ptr->id->port) {
Expand Down

0 comments on commit 39f056b

Please sign in to comment.