Skip to content

Commit

Permalink
db_mysql: if autoreconnect is set, then attemt 3 times if mysql ping …
Browse files Browse the repository at this point in the history
…fails

- it should help stalled/broken mysql tls connections to recover
  • Loading branch information
miconda committed Dec 7, 2015
1 parent b56fae6 commit 250c712
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/db_mysql/km_dbase.c
Expand Up @@ -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;
}
}
}
/*
Expand Down

0 comments on commit 250c712

Please sign in to comment.