Reset the following timestamp slot to avoid possible race-collisions (GC thread is not aligned to wall clock)

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2024-10-03 19:22:58 +02:00
parent 7ec1478018
commit 7e12e40840
+4 -2
View File
@@ -1219,11 +1219,12 @@ void update_qps(const time_t timestamp)
shmSettings->qps[slot]++;
}
// Reset queries per second (qps) value for a given timeslot
// Reset queries per second (qps) value for the timeslot following the current
// one
void reset_qps(const time_t timestamp)
{
// Get the timeslot for the current timestamp
const unsigned int slot = timestamp % QPS_AVGLEN;
const unsigned int slot = (timestamp + 1) % QPS_AVGLEN;
// Reset the query count
shmSettings->qps[slot] = 0;
@@ -1241,5 +1242,6 @@ double __attribute__((pure)) get_qps(void)
for(unsigned int i = 0; i < QPS_AVGLEN; i++)
qps += shmSettings->qps[i];
// Return the computed value divided by N (the number of slots)
return qps / QPS_AVGLEN;
}