forked from Archive/PX4-Autopilot
dataman_client: prevent loading duplicates in the cache
This commit is contained in:
parent
80409672b1
commit
e14216c6c7
|
@ -615,8 +615,21 @@ bool DatamanCache::load(dm_item_t item, uint32_t index)
|
|||
}
|
||||
|
||||
bool success = false;
|
||||
bool duplicate = false;
|
||||
|
||||
if (_item_counter < _num_items) {
|
||||
//Prevent duplicates
|
||||
for (uint32_t i = 0; i < _num_items; ++i) {
|
||||
|
||||
if (_items[i].cache_state != State::Idle &&
|
||||
_items[i].cache_state != State::Error &&
|
||||
_items[i].response.item == item &&
|
||||
_items[i].response.index == index) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!duplicate && (_item_counter < _num_items)) {
|
||||
|
||||
_items[_load_index].cache_state = State::RequestPrepared;
|
||||
_items[_load_index].response.item = item;
|
||||
|
|
Loading…
Reference in New Issue