diff --git a/src/fdb_kvdb.c b/src/fdb_kvdb.c index 123ab3e..0f48395 100644 --- a/src/fdb_kvdb.c +++ b/src/fdb_kvdb.c @@ -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 */ 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); if (result != FDB_NO_ERR) { goto __exit; @@ -1806,6 +1809,9 @@ __exit: _fdb_init_finish((fdb_db_t)db, result); + /* unlock the KVDB */ + db_unlock(db); + return result; } diff --git a/src/fdb_tsdb.c b/src/fdb_tsdb.c index e6c5dd6..ffe3cbb 100644 --- a/src/fdb_tsdb.c +++ b/src/fdb_tsdb.c @@ -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); + /* lock the TSDB */ + db_lock(db); + result = _fdb_init_ex((fdb_db_t)db, name, path, FDB_DB_TYPE_TS, user_data); if (result != FDB_NO_ERR) { goto __exit; @@ -996,6 +999,9 @@ __exit: _fdb_init_finish((fdb_db_t)db, result); + /* unlock the TSDB */ + db_unlock(db); + return result; }