fix: avoid rpc mem leak
This commit is contained in:
parent
ed1c777b4e
commit
de8bb6c25c
|
@ -232,6 +232,7 @@ typedef struct {
|
|||
SAsyncPool* transCreateAsyncPool(uv_loop_t* loop, int sz, void* arg, AsyncCB cb);
|
||||
void transDestroyAsyncPool(SAsyncPool* pool);
|
||||
int transAsyncSend(SAsyncPool* pool, queue* mq);
|
||||
bool transAsyncPoolIsEmpty(SAsyncPool* pool);
|
||||
|
||||
#define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc) \
|
||||
do { \
|
||||
|
|
|
@ -70,6 +70,8 @@ typedef struct SCliThrd {
|
|||
|
||||
SCvtAddr cvtAddr;
|
||||
|
||||
SCliMsg* stopMsg;
|
||||
|
||||
bool quit;
|
||||
} SCliThrd;
|
||||
|
||||
|
@ -761,14 +763,17 @@ void cliConnCb(uv_connect_t* req, int status) {
|
|||
}
|
||||
|
||||
static void cliHandleQuit(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||
if (!transAsyncPoolIsEmpty(pThrd->asyncPool)) {
|
||||
pThrd->stopMsg = pMsg;
|
||||
return;
|
||||
}
|
||||
pThrd->stopMsg = NULL;
|
||||
pThrd->quit = true;
|
||||
tDebug("cli work thread %p start to quit", pThrd);
|
||||
destroyCmsg(pMsg);
|
||||
destroyConnPool(pThrd->pool);
|
||||
uv_timer_stop(&pThrd->timer);
|
||||
uv_walk(pThrd->loop, cliWalkCb, NULL);
|
||||
|
||||
// uv_stop(pThrd->loop);
|
||||
}
|
||||
static void cliHandleRelease(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||
int64_t refId = (int64_t)(pMsg->msg.info.handle);
|
||||
|
@ -925,6 +930,7 @@ static void cliAsyncCb(uv_async_t* handle) {
|
|||
if (count >= 2) {
|
||||
tTrace("cli process batch size:%d", count);
|
||||
}
|
||||
if (pThrd->stopMsg != NULL) cliHandleQuit(pThrd->stopMsg, pThrd);
|
||||
}
|
||||
|
||||
static void* cliWorkThread(void* arg) {
|
||||
|
|
|
@ -228,6 +228,14 @@ int transAsyncSend(SAsyncPool* pool, queue* q) {
|
|||
}
|
||||
return uv_async_send(async);
|
||||
}
|
||||
bool transAsyncPoolIsEmpty(SAsyncPool* pool) {
|
||||
for (int i = 0; i < pool->nAsync; i++) {
|
||||
uv_async_t* async = &(pool->asyncs[i]);
|
||||
SAsyncItem* item = async->data;
|
||||
if (!QUEUE_IS_EMPTY(&item->qmsg)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void transCtxInit(STransCtx* ctx) {
|
||||
// init transCtx
|
||||
|
|
Loading…
Reference in New Issue