[sr-dev] git:4.3:8d8a4306: db_mysql: explicitely set the reconenct flag via mysql cloent api

Daniel-Constantin Mierla miconda at gmail.com
Wed Nov 25 13:06:07 CET 2015


Module: kamailio
Branch: 4.3
Commit: 8d8a43064f6ba7419473b139997f44bd4ef698a5
URL: https://github.com/kamailio/kamailio/commit/8d8a43064f6ba7419473b139997f44bd4ef698a5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-11-25T13:05:46+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

(cherry picked from commit e89c77f641311415b13b00dc9d469c0424362d53)

---

Modified: modules/db_mysql/km_my_con.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8d8a43064f6ba7419473b139997f44bd4ef698a5.diff
Patch: https://github.com/kamailio/kamailio/commit/8d8a43064f6ba7419473b139997f44bd4ef698a5.patch

---

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;




More information about the sr-dev mailing list