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,11 +2473,12 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
} }
int tdbBtcClose(SBTC *pBtc) { int tdbBtcClose(SBTC *pBtc) {
if (pBtc->iPage < 0) {
if (pBtc->freeTxn) { if (pBtc->freeTxn) {
tdbTxnClose(pBtc->pTxn); tdbTxnClose(pBtc->pTxn);
} }
return 0;
if (pBtc->iPage < 0) return 0; }
for (;;) { for (;;) {
if (NULL == pBtc->pPage) { if (NULL == pBtc->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;
} }