diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c index c55b81d5453..e4ded27a873 100644 --- a/modules/db_mysql/km_my_con.c +++ b/modules/db_mysql/km_my_con.c @@ -44,6 +44,9 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) { struct my_con* ptr; char *host, *grp, *egrp; +#if MYSQL_VERSION_ID > 50012 + my_bool rec; +#endif if (!id) { LM_ERR("invalid parameter value\n"); @@ -100,6 +103,13 @@ struct my_con* db_mysql_new_connection(const struct db_id* id) mysql_options(ptr->con, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&db_mysql_timeout_interval); mysql_options(ptr->con, MYSQL_OPT_READ_TIMEOUT, (const char *)&db_mysql_timeout_interval); mysql_options(ptr->con, MYSQL_OPT_WRITE_TIMEOUT, (const char *)&db_mysql_timeout_interval); +#if MYSQL_VERSION_ID > 50012 + /* set reconnect flag if enabled */ + if (db_mysql_auto_reconnect) { + rec = 1; + mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &rec); + } +#endif #if (MYSQL_VERSION_ID >= 40100) if (!mysql_real_connect(ptr->con, host, id->username, id->password,