diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 54ffcabc8d..064c110a9f 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -60,6 +60,7 @@ typedef struct SCliThrd { int64_t pid; // pid uv_loop_t* loop; SAsyncPool* asyncPool; + uv_idle_t* idle; uv_timer_t timer; void* pool; // conn pool @@ -116,6 +117,7 @@ static void cliSendCb(uv_write_t* req, int status); // callback after conn to server static void cliConnCb(uv_connect_t* req, int status); static void cliAsyncCb(uv_async_t* handle); +static void cliIdleCb(uv_idle_t* handle); static int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg); @@ -962,6 +964,10 @@ static void cliAsyncCb(uv_async_t* handle) { } if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd->stopMsg, pThrd); } +static void cliIdleCb(uv_idle_t* handle) { + SCliThrd* thrd = handle->data; + tTrace("do idle work"); +} static void* cliWorkThread(void* arg) { SCliThrd* pThrd = (SCliThrd*)arg; @@ -1024,6 +1030,11 @@ static SCliThrd* createThrdObj() { uv_timer_init(pThrd->loop, &pThrd->timer); pThrd->timer.data = pThrd; + // pThrd->idle = taosMemoryCalloc(1, sizeof(uv_idle_t)); + // uv_idle_init(pThrd->loop, pThrd->idle); + // pThrd->idle->data = pThrd; + // uv_idle_start(pThrd->idle, cliIdleCb); + pThrd->pool = createConnPool(4); transDQCreate(pThrd->loop, &pThrd->delayQueue); @@ -1045,6 +1056,8 @@ static void destroyThrdObj(SCliThrd* pThrd) { transDQDestroy(pThrd->delayQueue, destroyCmsg); transDQDestroy(pThrd->timeoutQueue, NULL); + + taosMemoryFree(pThrd->idle); taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index fb59aafb33..c99effb26f 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -152,16 +152,18 @@ int transDumpFromBuffer(SConnBuffer* connBuf, char** buf) { int transResetBuffer(SConnBuffer* connBuf) { SConnBuffer* p = connBuf; - if (p->total <= p->len) { + if (p->total < p->len) { int left = p->len - p->total; memmove(p->buf, p->buf + p->total, left); p->left = -1; p->total = 0; p->len = left; - } else { + } else if (p->total == p->len) { p->left = -1; p->total = 0; p->len = 0; + } else { + assert(0); } return 0; } diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index e360926b40..a97e0b53c1 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -238,7 +238,7 @@ static void uvHandleReq(SSvrConn* pConn) { transMsg.msgType = pHead->msgType; transMsg.code = pHead->code; - transClearBuffer(&pConn->readBuf); + // transClearBuffer(&pConn->readBuf); pConn->inType = pHead->msgType; if (pConn->status == ConnNormal) {