refact code

This commit is contained in:
Hongze Cheng 2023-01-10 09:56:38 +08:00
parent 1dfeaf8b18
commit 851dba5166
1 changed files with 9 additions and 12 deletions

View File

@ -81,6 +81,7 @@ _exit:
} }
static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) { static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
int32_t code = 0; int32_t code = 0;
int32_t lino = 0;
taosThreadMutexLock(&pVnode->mutex); taosThreadMutexLock(&pVnode->mutex);
@ -100,12 +101,8 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
} else { } else {
vInfo("vgId:%d no free buffer pool on %d try, try to recycle...", TD_VID(pVnode), nTry); vInfo("vgId:%d no free buffer pool on %d try, try to recycle...", TD_VID(pVnode), nTry);
terrno = vnodeTryRecycleBufPool(pVnode); code = vnodeTryRecycleBufPool(pVnode);
if (terrno != TSDB_CODE_SUCCESS) { TSDB_CHECK_CODE(code, lino, _exit);
vError("vgId:%d %s failed since %s", TD_VID(pVnode), __func__, tstrerror(terrno));
taosThreadMutexUnlock(&pVnode->mutex);
return -1;
}
if (pVnode->freeList == NULL) { if (pVnode->freeList == NULL) {
vDebug("vgId:%d no free buffer pool on %d try, wait %d ms...", TD_VID(pVnode), nTry, WAIT_TIME_MILI_SEC); vDebug("vgId:%d no free buffer pool on %d try, wait %d ms...", TD_VID(pVnode), nTry, WAIT_TIME_MILI_SEC);
@ -118,18 +115,18 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
int32_t rc = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts); int32_t rc = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
if (rc && rc != ETIMEDOUT) { if (rc && rc != ETIMEDOUT) {
terrno = TAOS_SYSTEM_ERROR(rc); code = TAOS_SYSTEM_ERROR(rc);
vError("vgId:%d %s failed since %s", TD_VID(pVnode), __func__, tstrerror(terrno)); TSDB_CHECK_CODE(code, lino, _exit);
taosThreadMutexUnlock(&pVnode->mutex);
return -1;
} }
} }
} }
} }
taosThreadMutexUnlock(&pVnode->mutex);
_exit: _exit:
taosThreadMutexUnlock(&pVnode->mutex);
if (code) {
vError("vgId:%d %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code));
}
return code; return code;
} }
int vnodeBegin(SVnode *pVnode) { int vnodeBegin(SVnode *pVnode) {