[fdb] Add the lock in database init function.

This commit is contained in:
armink 2023-11-19 11:30:45 +08:00
parent 2dea1b2b88
commit 7e91b05483
2 changed files with 12 additions and 0 deletions

View File

@ -1754,6 +1754,9 @@ fdb_err_t fdb_kvdb_init(fdb_kvdb_t db, const char *name, const char *path, struc
/* must be aligned with write granularity */ /* must be aligned with write granularity */
FDB_ASSERT((FDB_STR_KV_VALUE_MAX_SIZE * 8) % FDB_WRITE_GRAN == 0); FDB_ASSERT((FDB_STR_KV_VALUE_MAX_SIZE * 8) % FDB_WRITE_GRAN == 0);
/* lock the KVDB */
db_lock(db);
result = _fdb_init_ex((fdb_db_t) db, name, path, FDB_DB_TYPE_KV, user_data); result = _fdb_init_ex((fdb_db_t) db, name, path, FDB_DB_TYPE_KV, user_data);
if (result != FDB_NO_ERR) { if (result != FDB_NO_ERR) {
goto __exit; goto __exit;
@ -1806,6 +1809,9 @@ __exit:
_fdb_init_finish((fdb_db_t)db, result); _fdb_init_finish((fdb_db_t)db, result);
/* unlock the KVDB */
db_unlock(db);
return result; return result;
} }

View File

@ -927,6 +927,9 @@ fdb_err_t fdb_tsdb_init(fdb_tsdb_t db, const char *name, const char *path, fdb_g
FDB_ASSERT(get_time); FDB_ASSERT(get_time);
/* lock the TSDB */
db_lock(db);
result = _fdb_init_ex((fdb_db_t)db, name, path, FDB_DB_TYPE_TS, user_data); result = _fdb_init_ex((fdb_db_t)db, name, path, FDB_DB_TYPE_TS, user_data);
if (result != FDB_NO_ERR) { if (result != FDB_NO_ERR) {
goto __exit; goto __exit;
@ -996,6 +999,9 @@ __exit:
_fdb_init_finish((fdb_db_t)db, result); _fdb_init_finish((fdb_db_t)db, result);
/* unlock the TSDB */
db_unlock(db);
return result; return result;
} }