Browse code

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

Daniel-Constantin Mierla authored on 23/11/2015 17:17:48
Showing 1 changed files
... ...
@@ -43,6 +43,9 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
43 43
 	struct my_con* ptr;
44 44
 	char *host, *grp, *egrp;
45 45
 	unsigned int connection_flag = 0;
46
+#if MYSQL_VERSION_ID > 50012
47
+	my_bool rec;
48
+#endif
46 49
 
47 50
 	if (!id) {
48 51
 		LM_ERR("invalid parameter value\n");
... ...
@@ -99,6 +102,13 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
99 102
 	mysql_options(ptr->con, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&db_mysql_timeout_interval);
100 103
 	mysql_options(ptr->con, MYSQL_OPT_READ_TIMEOUT, (const char *)&db_mysql_timeout_interval);
101 104
 	mysql_options(ptr->con, MYSQL_OPT_WRITE_TIMEOUT, (const char *)&db_mysql_timeout_interval);
105
+#if MYSQL_VERSION_ID > 50012
106
+	/* set reconnect flag if enabled */
107
+	if (db_mysql_auto_reconnect) {
108
+		rec = 1;
109
+		mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &rec);
110
+	}
111
+#endif
102 112
 
103 113
 	if (db_mysql_update_affected_found) { 
104 114
 	    connection_flag |= CLIENT_FOUND_ROWS;