more
This commit is contained in:
parent
c66a3ba0ee
commit
c8f23a801d
|
@ -25,7 +25,6 @@ struct SMetaDB {
|
||||||
|
|
||||||
int metaOpenDB(SMeta *pMeta) {
|
int metaOpenDB(SMeta *pMeta) {
|
||||||
int ret;
|
int ret;
|
||||||
char dbname[128];
|
|
||||||
|
|
||||||
pMeta->pDB = (SMetaDB *)calloc(1, sizeof(SMetaDB));
|
pMeta->pDB = (SMetaDB *)calloc(1, sizeof(SMetaDB));
|
||||||
if (pMeta->pDB == NULL) {
|
if (pMeta->pDB == NULL) {
|
||||||
|
@ -34,6 +33,17 @@ int metaOpenDB(SMeta *pMeta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: create the env
|
// TODO: create the env
|
||||||
|
ret = db_env_create(&(pMeta->pDB->pEvn), 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
// TODO: handle error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = pMeta->pDB->pEvn->open(pMeta->pDB->pEvn, pMeta->path, DB_CREATE | DB_INIT_MPOOL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
// TODO: handle error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = db_create(&(pMeta->pDB->pDB), pMeta->pDB->pEvn, 0);
|
ret = db_create(&(pMeta->pDB->pDB), pMeta->pDB->pEvn, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -77,7 +87,21 @@ int metaOpenDB(SMeta *pMeta) {
|
||||||
|
|
||||||
void metaCloseDB(SMeta *pMeta) {
|
void metaCloseDB(SMeta *pMeta) {
|
||||||
if (pMeta->pDB) {
|
if (pMeta->pDB) {
|
||||||
/* TODO */
|
if (pMeta->pDB->pIdx) {
|
||||||
|
pMeta->pDB->pIdx->close(pMeta->pDB->pIdx, 0);
|
||||||
|
pMeta->pDB->pIdx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->pDB->pDB) {
|
||||||
|
pMeta->pDB->pDB->close(pMeta->pDB->pDB, 0);
|
||||||
|
pMeta->pDB->pDB = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMeta->pDB->pEvn) {
|
||||||
|
pMeta->pDB->pEvn->close(pMeta->pDB->pEvn, 0);
|
||||||
|
pMeta->pDB->pEvn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free(pMeta->pDB);
|
free(pMeta->pDB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue