Module: kamailio
Branch: 4.2
Commit: 5093871c5e612c6a949e2b2ab043fbc24551a2ba
URL:
https://github.com/kamailio/kamailio/commit/5093871c5e612c6a949e2b2ab043fbc…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Juha Heinanen <jh(a)tutpro.com>
Date: 2015-12-22T00:56:43+02:00
db_mysql: explicitely set the reconenct flag via mysql cloent api
- old mode setting connection fied directly still in place, but now
should be safer if that changes
(cherry picked from commit e89c77f641311415b13b00dc9d469c0424362d53)
(cherry picked from commit 8d8a43064f6ba7419473b139997f44bd4ef698a5)
Conflicts:
modules/db_mysql/km_my_con.c
---
Modified: modules/db_mysql/km_my_con.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5093871c5e612c6a949e2b2ab043fbc…
Patch:
https://github.com/kamailio/kamailio/commit/5093871c5e612c6a949e2b2ab043fbc…
---
diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c
index c55b81d..e4ded27 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,