mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-08 06:24:34 +00:00
Added fix for handling mysql reconnect
This commit is contained in:
parent
fe9f1217ef
commit
a220e593c5
1 changed files with 5 additions and 1 deletions
|
|
@ -28,6 +28,7 @@
|
|||
MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) {
|
||||
MYSQL *rc;
|
||||
char sql[1024];
|
||||
my_bool reconnect = 1; /* Reconnect in case of timeout */
|
||||
|
||||
db_operational = false;
|
||||
|
||||
|
|
@ -36,6 +37,8 @@ MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) {
|
|||
return;
|
||||
}
|
||||
|
||||
mysql_options(&mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
rc = mysql_real_connect(&mysql,
|
||||
ntop->getPrefs()->get_mysql_host(),
|
||||
ntop->getPrefs()->get_mysql_user(),
|
||||
|
|
@ -97,7 +100,7 @@ MySQLDB::MySQLDB(NetworkInterface *_iface) : DB(_iface) {
|
|||
if(exec_sql_query(sql, 0) != 0) {
|
||||
ntop->getTrace()->traceEvent(TRACE_ERROR, "MySQL error: %s\n", get_last_db_error());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ntop->getTrace()->traceEvent(TRACE_NORMAL, "Succesfully connected to MySQL [%s:%s]\n",
|
||||
ntop->getPrefs()->get_mysql_host(),
|
||||
|
|
@ -166,6 +169,7 @@ bool MySQLDB::dumpV6Flow(time_t when, Flow *f, char *json) {
|
|||
|
||||
if(exec_sql_query(sql, 0) != 0) {
|
||||
ntop->getTrace()->traceEvent(TRACE_ERROR, "MySQL error: %s\n", get_last_db_error());
|
||||
printf("\n%s\n", sql);
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue