Added backlog replay threshold, currently one day

master
Richard Meadows 2015-07-18 17:03:45 +01:00
rodzic 93dd085729
commit 413e116707
2 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -45,6 +45,10 @@
* Address offset in memory
*/
#define BACKLOG_ADDRESS 0
/**
* Defines the number of backlogs that should be valid before we start replaying
*/
#define BACKLOG_REPLAY_THRESHOLD 24 /* One day */
void record_backlog(tracker_datapoint* dp);
struct tracker_datapoint* get_backlog(void);

Wyświetl plik

@ -226,6 +226,23 @@ struct tracker_datapoint* read_check_backlog_item(uint16_t index)
return (struct tracker_datapoint*)buffer;
}
/**
* Returns the number of backlogs indicated as valid in is_backlog_valid.
*
* Should correspond with the actual number of valid backlogs
*/
uint16_t is_backlog_valid_count(void)
{
uint16_t i, count = 0;
for (i = 0; i < BACKLOG_COUNT; i++) {
if (is_backlog_valid[i] == BACKLOG_VALID_FLAG) {
count++;
}
}
return count;
}
/**
* Gets a valid backlog item. Returns NULL if none available.
*/
@ -238,6 +255,11 @@ struct tracker_datapoint* get_backlog(void)
load_is_backlog_valid();
}
/* Return early if we haven't reached our replay threshold */
if (is_backlog_valid_count() < BACKLOG_REPLAY_THRESHOLD) {
return NULL;
}
for (i = 0; i < BACKLOG_COUNT; i++) {
/* Find an read index we think is valid */