fix mem leak

This commit is contained in:
yihaoDeng 2024-09-11 14:45:03 +08:00
parent cffa2a496c
commit 6c610e4777
2 changed files with 13 additions and 2 deletions

View File

@ -2422,7 +2422,6 @@ static void destroyThrdObj(SCliThrd* pThrd) {
tDebug("thread destroy %" PRId64, pThrd->pid); tDebug("thread destroy %" PRId64, pThrd->pid);
for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) { for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) {
uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i); uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i);
(void)uv_timer_stop(timer);
taosMemoryFree(timer); taosMemoryFree(timer);
} }

View File

@ -1398,10 +1398,21 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
thrd->quit = false; thrd->quit = false;
thrd->pTransInst = shandle; thrd->pTransInst = shandle;
thrd->pWhiteList = uvWhiteListCreate(); thrd->pWhiteList = uvWhiteListCreate();
if (thrd->pWhiteList == NULL) {
destroyWorkThrdObj(thrd);
code = TSDB_CODE_OUT_OF_MEMORY;
goto End;
}
srv->pThreadObj[i] = thrd;
srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t));
if (srv->pipe[i] == NULL) {
destroyWorkThrdObj(thrd);
code = TSDB_CODE_OUT_OF_MEMORY;
goto End;
}
thrd->pipe = &(srv->pipe[i][1]); // init read thrd->pipe = &(srv->pipe[i][1]); // init read
srv->pThreadObj[i] = thrd;
if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) { if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) {
goto End; goto End;
@ -1415,6 +1426,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
tError("failed to create worker-thread:%d", i); tError("failed to create worker-thread:%d", i);
goto End; goto End;
} }
thrd->inited = 1;
} }
#else #else