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

chore: revert the code change

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