[tsdb] fix the fdb_tsl_iter_by_time query issue.

This commit is contained in:
armink 2020-07-06 22:47:51 +08:00
parent 65a4b8968a
commit 8fb75abea0
1 changed files with 4 additions and 3 deletions

View File

@ -456,7 +456,7 @@ void fdb_tsl_iter(fdb_tsdb_t db, fdb_tsl_cb cb, void *arg)
void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl_cb cb, void *cb_arg) void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl_cb cb, void *cb_arg)
{ {
struct tsdb_sec_info sector; struct tsdb_sec_info sector;
uint32_t sec_addr, traversed_len = 0; uint32_t sec_addr, oldest_addr = db->oldest_addr, traversed_len = 0;
struct fdb_tsl tsl; struct fdb_tsl tsl;
bool found_start_tsl = false; bool found_start_tsl = false;
@ -471,7 +471,7 @@ void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl
return; return;
} }
sec_addr = db->oldest_addr; sec_addr = oldest_addr;
/* search all sectors */ /* search all sectors */
do { do {
if (read_sector_info(db, sec_addr, &sector, false) != FDB_NO_ERR) { if (read_sector_info(db, sec_addr, &sector, false) != FDB_NO_ERR) {
@ -483,7 +483,8 @@ void fdb_tsl_iter_by_time(fdb_tsdb_t db, fdb_time_t from, fdb_time_t to, fdb_tsl
/* copy the current using sector status */ /* copy the current using sector status */
sector = db->cur_sec; sector = db->cur_sec;
} }
if ((!found_start_tsl && (from >= sector.start_time && from <= sector.end_time)) || (found_start_tsl)) { if ((!found_start_tsl && ((from >= sector.start_time && from <= sector.end_time)
|| (sec_addr == oldest_addr && from <= sector.start_time))) || (found_start_tsl)) {
uint32_t start = sector.addr + SECTOR_HDR_DATA_SIZE, end = sector.end_idx; uint32_t start = sector.addr + SECTOR_HDR_DATA_SIZE, end = sector.end_idx;
found_start_tsl = true; found_start_tsl = true;