diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 2972f512f1..37ee1f4b0c 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -392,7 +392,7 @@ typedef struct SDelayQueue { } SDelayQueue; 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); bool transEpSetIsEqual(SEpSet* a, SEpSet* b); diff --git a/source/libs/transport/src/.transComm.c.swo b/source/libs/transport/src/.transComm.c.swo new file mode 100644 index 0000000000..72ffc92ce9 Binary files /dev/null and b/source/libs/transport/src/.transComm.c.swo differ diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index be3111e870..fb0598d247 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -140,7 +140,7 @@ static void destroyUserdata(STransMsg* userdata); static int cliRBChoseIdx(STrans* pTransInst); -static void destroyCmsg(SCliMsg* cmsg); +static void destroyCmsg(void* cmsg); static void transDestroyConnCtx(STransConnCtx* ctx); // thread obj static SCliThrd* createThrdObj(); @@ -962,7 +962,8 @@ static void destroyUserdata(STransMsg* userdata) { transFreeMsg(userdata->pCont); userdata->pCont = NULL; } -static void destroyCmsg(SCliMsg* pMsg) { +static void destroyCmsg(void* arg) { + SCliMsg* pMsg = arg; if (pMsg == NULL) { return; } @@ -1001,7 +1002,7 @@ static void destroyThrdObj(SCliThrd* pThrd) { TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsg); transDestroyAsyncPool(pThrd->asyncPool); - transDQDestroy(pThrd->delayQueue); + transDQDestroy(pThrd->delayQueue, destroyCmsg); taosMemoryFree(pThrd->loop); taosMemoryFree(pThrd); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 84af8da513..0a2d3a13ff 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -456,7 +456,7 @@ int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { return 0; } -void transDQDestroy(SDelayQueue* queue) { +void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) { taosMemoryFree(queue->timer); while (heapSize(queue->heap) > 0) { @@ -467,6 +467,11 @@ void transDQDestroy(SDelayQueue* queue) { heapRemove(queue->heap, minNode); SDelayTask* task = container_of(minNode, SDelayTask, node); + + STaskArg* arg = task->arg; + freeFunc(arg->param1); + taosMemoryFree(arg); + taosMemoryFree(task); } heapDestroy(queue->heap);