提交 936daff0 编写于 作者: C Cary Xu

chore: revert the code change

上级 5651bde6
......@@ -65,7 +65,6 @@ struct SVBufPool {
SVnode* pVnode;
volatile int32_t nRef;
TdThreadSpinlock lock;
bool isLock;
int64_t size;
uint8_t* ptr;
SVBufPoolNode* pTail;
......
......@@ -27,15 +27,10 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
return -1;
}
if (VND_IS_RSMA(pVnode)) {
if (taosThreadSpinInit(&pPool->lock, 0) != 0) {
taosMemoryFree(pPool);
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
pPool->isLock = true;
} else {
pPool->isLock = false;
if (taosThreadSpinInit(&pPool->lock, 0) != 0) {
taosMemoryFree(pPool);
terrno = TAOS_SYSTEM_ERROR(errno);
return -1;
}
pPool->next = NULL;
......@@ -54,9 +49,7 @@ static int vnodeBufPoolCreate(SVnode *pVnode, int64_t size, SVBufPool **ppPool)
static int vnodeBufPoolDestroy(SVBufPool *pPool) {
vnodeBufPoolReset(pPool);
if (pPool->isLock) {
taosThreadSpinDestroy(&pPool->lock);
}
taosThreadSpinDestroy(&pPool->lock);
taosMemoryFree(pPool);
return 0;
}
......@@ -121,9 +114,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
void *p = NULL;
ASSERT(pPool != NULL);
if (pPool->isLock) {
taosThreadSpinLock(&pPool->lock);
}
taosThreadSpinLock(&pPool->lock);
if (pPool->node.size >= pPool->ptr - pPool->node.data + size) {
// allocate from the anchor node
......@@ -135,9 +126,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
pNode = taosMemoryMalloc(sizeof(*pNode) + size);
if (pNode == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
if (pPool->isLock) {
taosThreadSpinUnlock(&pPool->lock);
}
taosThreadSpinUnlock(&pPool->lock);
return NULL;
}
......@@ -150,9 +139,8 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) {
pPool->size = pPool->size + sizeof(*pNode) + size;
}
if (pPool->isLock) {
taosThreadSpinUnlock(&pPool->lock);
}
taosThreadSpinUnlock(&pPool->lock);
return p;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册