void* MySQLDB::queryLoop() { Redis *r = ntop->getRedis(); MYSQL mysql_alt; if(connectToDB(&mysql_alt, true) == false) return(NULL); while(!ntop->getGlobals()->isShutdown()) { char sql[2048]; int rc = r->lpop(CONST_SQL_QUEUE, sql, sizeof(sql)); if(rc == 0) { if(exec_sql_query(&mysql_alt, sql, true, true, false) != 0) { ntop->getTrace()->traceEvent(TRACE_ERROR, "MySQL error: %s", get_last_db_error(&mysql)); ntop->getTrace()->traceEvent(TRACE_ERROR, "%s", sql); } } else sleep(1); } mysql_close(&mysql_alt); return(NULL); }