diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 6afb18283..010531405 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1008,7 +1008,8 @@ __end_monitor_ping_loop: delete resultset; resultset=NULL; } - char *new_query=(char *)"SELECT 1 FROM (SELECT hostname,port,ping_error FROM mysql_server_ping_log WHERE hostname='%s' AND port='%s' ORDER BY time_start DESC LIMIT %d) a WHERE ping_error IS NOT NULL GROUP BY hostname,port HAVING COUNT(*)=%d"; + char *new_query=NULL; + new_query=(char *)"SELECT 1 FROM (SELECT hostname,port,ping_error FROM mysql_server_ping_log WHERE hostname='%s' AND port='%s' ORDER BY time_start DESC LIMIT %d) a WHERE ping_error IS NOT NULL GROUP BY hostname,port HAVING COUNT(*)=%d"; for (j=0;jexecute_statement(buff, &error , &cols , &affected_rows , &resultset); + if (!error) { + if (resultset) { + if (resultset->rows_count) { + for (std::vector::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) { + SQLite3_row *r=*it; // this should be called just once, but we create a generic for loop + // update curreny_latency_ms + MyHGM->set_server_current_latency_us(addresses[j],atoi(ports[j]), atoi(r->fields[2])); + } + } + delete resultset; + resultset=NULL; + } + } else { + proxy_error("Error on %s : %s\n", query, error); + } + free(buff); + } + while (i) { // now free all the addresses/ports i--; free(addresses[i]);