Module: kamailio
Branch: master
Commit: 250c7125613fc0fc26b72f68a7d0bd63a4a1b430
URL:
https://github.com/kamailio/kamailio/commit/250c7125613fc0fc26b72f68a7d0bd6…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-12-07T22:23:41+01:00
db_mysql: if autoreconnect is set, then attemt 3 times if mysql ping fails
- it should help stalled/broken mysql tls connections to recover
---
Modified: modules/db_mysql/km_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/250c7125613fc0fc26b72f68a7d0bd6…
Patch:
https://github.com/kamailio/kamailio/commit/250c7125613fc0fc26b72f68a7d0bd6…
---
diff --git a/modules/db_mysql/km_dbase.c b/modules/db_mysql/km_dbase.c
index 9b220c3..2b3d1c9 100644
--- a/modules/db_mysql/km_dbase.c
+++ b/modules/db_mysql/km_dbase.c
@@ -80,9 +80,13 @@ static int db_mysql_submit_query(const db1_con_t* _h, const str* _s)
if (my_ping_interval) {
t = time(0);
if ((t - CON_TIMESTAMP(_h)) > my_ping_interval) {
- if (mysql_ping(CON_CONNECTION(_h))) {
- LM_WARN("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
- counter_inc(mysql_cnts_h.driver_err);
+ for (i=0; i < (db_mysql_auto_reconnect ? 3 : 1); i++) {
+ if (mysql_ping(CON_CONNECTION(_h))) {
+ LM_WARN("driver error on ping: %s\n", mysql_error(CON_CONNECTION(_h)));
+ counter_inc(mysql_cnts_h.driver_err);
+ } else {
+ break;
+ }
}
}
/*