+ /* ==== Is this a part of a series of bogus events? ==== */
+ snprintf(statement, sizeof(statement),
+ "select timestamp from %scnt "
+ "where timestamp > subtime(\"%s\", \"0 0:0:10\") "
+ "order by timestamp desc;\n",
+ table, tstr);
+ if ((rc = mysql_query(&mysql, statement)))
+ g_warning("mysql \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ else if ((result = mysql_store_result(&mysql))){
+ my_ulonglong rows = mysql_num_rows(result);
+
+ if (rows > 0) {
+ bogus = 1;
+ MYSQL_ROW row = mysql_fetch_row(result);
+ if (row && *row) {
+ strncpy(prevtstr, *row, sizeof(prevtstr));
+ } else {
+ g_warning("mysql_fetch_row after \"%s\": "
+ "no result despite rows=%llu\n",
+ statement, rows);
+ bogus = -1;
+ }
+ }
+ if (rows == 1)
+ bogus = 2;
+
+ mysql_free_result(result);
+ }
+ if (bogus > 0) {
+ snprintf(statement, sizeof(statement),
+ "insert into %sadj values (\"%s\", -1);\n",
+ table, tstr);
+ g_info("%s %u at \"%s\" bogus, %s",
+ table, val, tstr, statement);
+ if ((rc = mysql_query(&mysql, statement)))
+ g_warning("mysql \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ }
+ if (bogus > 1) {
+ snprintf(statement, sizeof(statement),
+ "insert into %sadj values (\"%s\", -1);\n",
+ table, prevtstr);
+ g_info("previous %s at \"%s\" was bogus too, %s",
+ table, prevtstr, statement);
+ if ((rc = mysql_query(&mysql, statement)))
+ g_warning("mysql \"%s\" error: %s\n",
+ statement, mysql_error(&mysql));
+ }
+ /* ==== Update the counter table regardless ==== */