[tsdb] Fixed a bug (#108) when tsl is full on rollover mode. Thx @kenny-33 @illusionkiller .

This commit is contained in:
armink
2021-12-26 15:11:33 +08:00
parent bf3ac9ecaa
commit 83f1669773
2 changed files with 8 additions and 5 deletions
+2 -2
View File
@@ -17,8 +17,8 @@ extern "C" {
#endif
/* software version number */
#define FDB_SW_VERSION "1.1.0"
#define FDB_SW_VERSION_NUM 0x10100
#define FDB_SW_VERSION "1.1.1"
#define FDB_SW_VERSION_NUM 0x10101
/* the KV max name length must less then it */
#ifndef FDB_KV_NAME_MAX
+6 -3
View File
@@ -775,9 +775,12 @@ fdb_err_t fdb_tsdb_init(fdb_tsdb_t db, const char *name, const char *path, fdb_g
if (check_sec_arg.empty_num > 0) {
latest_addr = check_sec_arg.empty_addr;
} else {
latest_addr = db->cur_sec.addr;
/* There is no empty sector. */
latest_addr = db->cur_sec.addr = db_max_size(db) - db_sec_size(db);
if (db->rollover) {
latest_addr = db->cur_sec.addr;
} else {
/* There is no empty sector. */
latest_addr = db->cur_sec.addr = db_max_size(db) - db_sec_size(db);
}
}
/* db->cur_sec is the latest sector, and the next is the oldest sector */
if (latest_addr + db_sec_size(db) >= db_max_size(db)) {