Module: kamailio
Branch: master
Commit: c31535072a04273b52a5cbc015e7ed1423d5dc33
URL:
https://github.com/kamailio/kamailio/commit/c31535072a04273b52a5cbc015e7ed1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-11-03T08:23:29+01:00
db_mysql: do not set reconnect field explicitely for newer mysql versions
- exposed with MariaDB 10.2
- include mysql.h instead of mysql_version.h
- reported by GH #1296
---
Modified: src/modules/db_mysql/km_my_con.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c31535072a04273b52a5cbc015e7ed1…
Patch:
https://github.com/kamailio/kamailio/commit/c31535072a04273b52a5cbc015e7ed1…
---
diff --git a/src/modules/db_mysql/km_my_con.c b/src/modules/db_mysql/km_my_con.c
index b5f586dcf2..38e6875a19 100644
--- a/src/modules/db_mysql/km_my_con.c
+++ b/src/modules/db_mysql/km_my_con.c
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2001-2004
iptel.org
* Copyright (C) 2008 1&1 Internet AG
*
@@ -14,8 +14,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -28,7 +28,7 @@
#include "km_my_con.h"
#include "km_db_mysql.h"
-#include <mysql_version.h>
+#include <mysql.h>
#include "../../core/mem/mem.h"
#include "../../core/dprint.h"
#include "../../core/ut.h"
@@ -108,12 +108,17 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
rec = 1;
mysql_options(ptr->con, MYSQL_OPT_RECONNECT, &rec);
}
+#else
+ if (db_mysql_auto_reconnect)
+ ptr->con->reconnect = 1;
+ else
+ ptr->con->reconnect = 0;
#endif
- if (db_mysql_update_affected_found) {
+ if (db_mysql_update_affected_found) {
connection_flag |= CLIENT_FOUND_ROWS;
}
-
+
#if (MYSQL_VERSION_ID >= 40100)
if (!mysql_real_connect(ptr->con, host, id->username, id->password,
id->database, id->port, 0, connection_flag|CLIENT_MULTI_STATEMENTS)) {
@@ -127,11 +132,6 @@ struct my_con* db_mysql_new_connection(const struct db_id* id)
mysql_close(ptr->con);
goto err;
}
- /* force reconnection if enabled */
- if (db_mysql_auto_reconnect)
- ptr->con->reconnect = 1;
- else
- ptr->con->reconnect = 0;
LM_DBG("connection type is %s\n", mysql_get_host_info(ptr->con));
LM_DBG("protocol version is %d\n", mysql_get_proto_info(ptr->con));