Module: kamailio
Branch: master
Commit: e89c77f641311415b13b00dc9d469c0424362d53
URL:
https://github.com/kamailio/kamailio/commit/e89c77f641311415b13b00dc9d469c0…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-11-23T18:17:48+01: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
---
Modified: modules/db_mysql/km_my_con.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e89c77f641311415b13b00dc9d469c0…
Patch:
https://github.com/kamailio/kamailio/commit/e89c77f641311415b13b00dc9d469c0…
---
diff --git a/modules/db_mysql/km_my_con.c b/modules/db_mysql/km_my_con.c
index 5558d66..d5f4dd2 100644
--- a/modules/db_mysql/km_my_con.c
+++ b/modules/db_mysql/km_my_con.c
@@ -43,6 +43,9 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
struct my_con* ptr;
char *host, *grp, *egrp;
unsigned int connection_flag = 0;
+#if MYSQL_VERSION_ID > 50012
+ my_bool rec;
+#endif
if (!id) {
LM_ERR("invalid parameter value\n");
@@ -99,6 +102,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 (db_mysql_update_affected_found) {
connection_flag |= CLIENT_FOUND_ROWS;