[fdb] Improve the database lock uses in init function.
This commit is contained in:
parent
cb84e2c41d
commit
189b22e0a4
|
@ -1754,14 +1754,14 @@ 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;
|
||||
}
|
||||
|
||||
/* lock the KVDB */
|
||||
db_lock(db);
|
||||
|
||||
db->gc_request = false;
|
||||
db->in_recovery_check = false;
|
||||
if (default_kv) {
|
||||
|
@ -1805,13 +1805,13 @@ fdb_err_t fdb_kvdb_init(fdb_kvdb_t db, const char *name, const char *path, struc
|
|||
}
|
||||
#endif
|
||||
|
||||
/* unlock the KVDB */
|
||||
db_unlock(db);
|
||||
|
||||
__exit:
|
||||
|
||||
_fdb_init_finish((fdb_db_t)db, result);
|
||||
|
||||
/* unlock the KVDB */
|
||||
db_unlock(db);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -927,14 +927,14 @@ 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;
|
||||
}
|
||||
|
||||
/* lock the TSDB */
|
||||
db_lock(db);
|
||||
|
||||
db->get_time = get_time;
|
||||
db->max_len = max_len;
|
||||
/* default rollover flag is true */
|
||||
|
@ -995,13 +995,13 @@ fdb_err_t fdb_tsdb_init(fdb_tsdb_t db, const char *name, const char *path, fdb_g
|
|||
db->last_time = sec.end_time;
|
||||
}
|
||||
|
||||
/* unlock the TSDB */
|
||||
db_unlock(db);
|
||||
|
||||
__exit:
|
||||
|
||||
_fdb_init_finish((fdb_db_t)db, result);
|
||||
|
||||
/* unlock the TSDB */
|
||||
db_unlock(db);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue