refactor transport
This commit is contained in:
parent
02ff9967fb
commit
8c11a7e998
|
@ -212,8 +212,10 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd);
|
|||
static void cliHandleUpdate(SCliMsg* pMsg, SCliThrd* pThrd);
|
||||
static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq, cliHandleQuit, cliHandleRelease, NULL,
|
||||
cliHandleUpdate};
|
||||
/// static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq, cliHandleQuit, cliHandleRelease,
|
||||
/// NULL,cliHandleUpdate};
|
||||
|
||||
static void cliDealReq(queue* h, SCliThrd* pThrd);
|
||||
static void cliBatchDealReq(queue* h, SCliThrd* pThrd);
|
||||
static void (*cliDealFunc[])(queue* h, SCliThrd* pThrd) = {cliDealReq, cliBatchDealReq};
|
||||
|
||||
static FORCE_INLINE void destroyCmsg(void* cmsg);
|
||||
|
||||
|
@ -1695,7 +1697,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
|
|||
tGTrace("%s conn %p ready", pTransInst->label, conn);
|
||||
}
|
||||
|
||||
static void cliNoBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
||||
static void cliDealReq(queue* wq, SCliThrd* pThrd) {
|
||||
int count = 0;
|
||||
|
||||
while (!QUEUE_IS_EMPTY(wq)) {
|
||||
|
@ -1709,7 +1711,6 @@ static void cliNoBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
|||
continue;
|
||||
}
|
||||
(*cliAsyncHandle[pMsg->type])(pMsg, pThrd);
|
||||
|
||||
count++;
|
||||
}
|
||||
if (count >= 2) {
|
||||
|
@ -1729,23 +1730,8 @@ SCliBatch* cliGetHeadFromList(SCliBatchList* pList) {
|
|||
SCliBatch* batch = QUEUE_DATA(hr, SCliBatch, listq);
|
||||
return batch;
|
||||
}
|
||||
|
||||
static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
||||
static void cliBuildBatch(SCliMsg* pMsg, queue* h, SCliThrd* pThrd) {
|
||||
STrans* pInst = pThrd->pTransInst;
|
||||
|
||||
int count = 0;
|
||||
while (!QUEUE_IS_EMPTY(wq)) {
|
||||
queue* h = QUEUE_HEAD(wq);
|
||||
QUEUE_REMOVE(h);
|
||||
|
||||
SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q);
|
||||
|
||||
if (pMsg->type == Quit) {
|
||||
pThrd->stopMsg = pMsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pMsg->type == Normal && REQUEST_NO_RESP(&pMsg->msg)) {
|
||||
STransConnCtx* pCtx = pMsg->ctx;
|
||||
|
||||
char* ip = EPSET_GET_INUSE_IP(&pCtx->epSet);
|
||||
|
@ -1791,8 +1777,6 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
|||
|
||||
QUEUE_PUSH(&((*ppBatchList)->wq), &pBatch->listq);
|
||||
(*ppBatchList)->len += 1;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
queue* hdr = QUEUE_TAIL(&((*ppBatchList)->wq));
|
||||
|
@ -1815,6 +1799,25 @@ static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
|||
(*ppBatchList)->len += 1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
static void cliBatchDealReq(queue* wq, SCliThrd* pThrd) {
|
||||
STrans* pInst = pThrd->pTransInst;
|
||||
|
||||
int count = 0;
|
||||
while (!QUEUE_IS_EMPTY(wq)) {
|
||||
queue* h = QUEUE_HEAD(wq);
|
||||
QUEUE_REMOVE(h);
|
||||
|
||||
SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q);
|
||||
|
||||
if (pMsg->type == Quit) {
|
||||
pThrd->stopMsg = pMsg;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pMsg->type == Normal && REQUEST_NO_RESP(&pMsg->msg)) {
|
||||
cliBuildBatch(pMsg, h, pThrd);
|
||||
continue;
|
||||
}
|
||||
(*cliAsyncHandle[pMsg->type])(pMsg, pThrd);
|
||||
|
@ -1847,12 +1850,7 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
QUEUE_MOVE(&item->qmsg, &wq);
|
||||
taosThreadMutexUnlock(&item->mtx);
|
||||
|
||||
int8_t supportBatch = pTransInst->supportBatch;
|
||||
if (supportBatch == 0) {
|
||||
cliNoBatchDealReq(&wq, pThrd);
|
||||
} else if (supportBatch == 1) {
|
||||
cliBatchDealReq(&wq, pThrd);
|
||||
}
|
||||
cliDealFunc[pTransInst->supportBatch](&wq, pThrd);
|
||||
|
||||
if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd->stopMsg, pThrd);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue