提交 3a65f10f 编写于 作者: dengyihao's avatar dengyihao

fix: avoid rpc mem leak

上级 f93d465d
...@@ -392,7 +392,7 @@ typedef struct SDelayQueue { ...@@ -392,7 +392,7 @@ typedef struct SDelayQueue {
} SDelayQueue; } SDelayQueue;
int transDQCreate(uv_loop_t* loop, SDelayQueue** queue); int transDQCreate(uv_loop_t* loop, SDelayQueue** queue);
void transDQDestroy(SDelayQueue* queue); void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg));
int transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs); int transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs);
bool transEpSetIsEqual(SEpSet* a, SEpSet* b); bool transEpSetIsEqual(SEpSet* a, SEpSet* b);
......
...@@ -140,7 +140,7 @@ static void destroyUserdata(STransMsg* userdata); ...@@ -140,7 +140,7 @@ static void destroyUserdata(STransMsg* userdata);
static int cliRBChoseIdx(STrans* pTransInst); static int cliRBChoseIdx(STrans* pTransInst);
static void destroyCmsg(SCliMsg* cmsg); static void destroyCmsg(void* cmsg);
static void transDestroyConnCtx(STransConnCtx* ctx); static void transDestroyConnCtx(STransConnCtx* ctx);
// thread obj // thread obj
static SCliThrd* createThrdObj(); static SCliThrd* createThrdObj();
...@@ -962,7 +962,8 @@ static void destroyUserdata(STransMsg* userdata) { ...@@ -962,7 +962,8 @@ static void destroyUserdata(STransMsg* userdata) {
transFreeMsg(userdata->pCont); transFreeMsg(userdata->pCont);
userdata->pCont = NULL; userdata->pCont = NULL;
} }
static void destroyCmsg(SCliMsg* pMsg) { static void destroyCmsg(void* arg) {
SCliMsg* pMsg = arg;
if (pMsg == NULL) { if (pMsg == NULL) {
return; return;
} }
...@@ -1001,7 +1002,7 @@ static void destroyThrdObj(SCliThrd* pThrd) { ...@@ -1001,7 +1002,7 @@ static void destroyThrdObj(SCliThrd* pThrd) {
TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsg); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsg);
transDestroyAsyncPool(pThrd->asyncPool); transDestroyAsyncPool(pThrd->asyncPool);
transDQDestroy(pThrd->delayQueue); transDQDestroy(pThrd->delayQueue, destroyCmsg);
taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd->loop);
taosMemoryFree(pThrd); taosMemoryFree(pThrd);
} }
......
...@@ -456,7 +456,7 @@ int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { ...@@ -456,7 +456,7 @@ int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) {
return 0; return 0;
} }
void transDQDestroy(SDelayQueue* queue) { void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) {
taosMemoryFree(queue->timer); taosMemoryFree(queue->timer);
while (heapSize(queue->heap) > 0) { while (heapSize(queue->heap) > 0) {
...@@ -467,6 +467,11 @@ void transDQDestroy(SDelayQueue* queue) { ...@@ -467,6 +467,11 @@ void transDQDestroy(SDelayQueue* queue) {
heapRemove(queue->heap, minNode); heapRemove(queue->heap, minNode);
SDelayTask* task = container_of(minNode, SDelayTask, node); SDelayTask* task = container_of(minNode, SDelayTask, node);
STaskArg* arg = task->arg;
freeFunc(arg->param1);
taosMemoryFree(arg);
taosMemoryFree(task); taosMemoryFree(task);
} }
heapDestroy(queue->heap); heapDestroy(queue->heap);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册