btc/close: free txn only if iPage < 0

This commit is contained in:
Minglei Jin 2024-04-29 16:27:11 +08:00
parent d5f140aee2
commit 785faf50aa
1 changed files with 9 additions and 4 deletions

View File

@ -2473,12 +2473,13 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
} }
int tdbBtcClose(SBTC *pBtc) { int tdbBtcClose(SBTC *pBtc) {
if (pBtc->freeTxn) { if (pBtc->iPage < 0) {
tdbTxnClose(pBtc->pTxn); if (pBtc->freeTxn) {
tdbTxnClose(pBtc->pTxn);
}
return 0;
} }
if (pBtc->iPage < 0) return 0;
for (;;) { for (;;) {
if (NULL == pBtc->pPage) { if (NULL == pBtc->pPage) {
tdbError("tdb/btc-close: null ptr pPage."); tdbError("tdb/btc-close: null ptr pPage.");
@ -2500,6 +2501,10 @@ int tdbBtcClose(SBTC *pBtc) {
tdbFree(pBtc->coder.pVal); tdbFree(pBtc->coder.pVal);
} }
if (pBtc->freeTxn) {
tdbTxnClose(pBtc->pTxn);
}
return 0; return 0;
} }