From c643c48287cea81f12ceed068323a5b493438220 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 24 Mar 2022 15:53:01 +0800 Subject: [PATCH 1/3] handle except --- source/libs/transport/src/transComm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 2d6485b346..8b668092dd 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -280,6 +280,9 @@ void* transCtxDumpVal(STransCtx* ctx, int32_t key) { } void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { void *ret = NULL; + if (ctx->brokenVal.clone == NULL) { + return ret; + } (*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret); *msgType = ctx->brokenVal.msgType; From e0524091fbd3edd29a5ea1a3424c9f44dd597b28 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 24 Mar 2022 16:31:26 +0800 Subject: [PATCH 2/3] handle except --- source/libs/transport/src/transComm.c | 23 +++++++++++++++-------- source/libs/transport/src/transSrv.c | 3 +-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 8b668092dd..fd5bd18344 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -274,14 +274,14 @@ void* transCtxDumpVal(STransCtx* ctx, int32_t key) { if (cVal == NULL) { return NULL; } - void *ret = NULL; + void* ret = NULL; (*cVal->clone)(cVal->val, &ret); return ret; } void* transCtxDumpBrokenlinkVal(STransCtx* ctx, int32_t* msgType) { - void *ret = NULL; + void* ret = NULL; if (ctx->brokenVal.clone == NULL) { - return ret; + return ret; } (*ctx->brokenVal.clone)(ctx->brokenVal.val, &ret); @@ -295,6 +295,9 @@ void transQueueInit(STransQueue* queue, void (*free)(void* arg)) { queue->free = free; } bool transQueuePush(STransQueue* queue, void* arg) { + if (queue->q == NULL) { + return true; + } taosArrayPush(queue->q, &arg); if (taosArrayGetSize(queue->q) > 1) { return false; @@ -302,7 +305,7 @@ bool transQueuePush(STransQueue* queue, void* arg) { return true; } void* transQueuePop(STransQueue* queue) { - if (taosArrayGetSize(queue->q) == 0) { + if (queue->q == NULL || taosArrayGetSize(queue->q) == 0) { return NULL; } void* ptr = taosArrayGetP(queue->q, 0); @@ -310,11 +313,13 @@ void* transQueuePop(STransQueue* queue) { return ptr; } int32_t transQueueSize(STransQueue* queue) { - // Get size + if (queue->q == NULL) { + return 0; + } return taosArrayGetSize(queue->q); } void* transQueueGet(STransQueue* queue, int i) { - if (taosArrayGetSize(queue->q) == 0) { + if (queue->q == NULL || taosArrayGetSize(queue->q) == 0) { return NULL; } if (i >= taosArrayGetSize(queue->q)) { @@ -326,7 +331,7 @@ void* transQueueGet(STransQueue* queue, int i) { } void* transQueueRm(STransQueue* queue, int i) { - if (taosArrayGetSize(queue->q) == 0) { + if (queue->q == NULL || taosArrayGetSize(queue->q) == 0) { return NULL; } if (i >= taosArrayGetSize(queue->q)) { @@ -338,7 +343,9 @@ void* transQueueRm(STransQueue* queue, int i) { } bool transQueueEmpty(STransQueue* queue) { - // + if (queue->q == NULL) { + return true; + } return taosArrayGetSize(queue->q) == 0; } void transQueueClear(STransQueue* queue) { diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 15dcc29232..b4052aea46 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -623,8 +623,6 @@ static void destroyConn(SSrvConn* conn, bool clear) { return; } transDestroyBuffer(&conn->readBuf); - - transQueueDestroy(&conn->srvMsgs); if (clear) { tTrace("server conn %p to be destroyed", conn); uv_shutdown_t* req = malloc(sizeof(uv_shutdown_t)); @@ -640,6 +638,7 @@ static void uvDestroyConn(uv_handle_t* handle) { tDebug("server conn %p destroy", conn); uv_timer_stop(&conn->pTimer); + transQueueDestroy(&conn->srvMsgs); QUEUE_REMOVE(&conn->queue); free(conn->pTcp); // free(conn); From c563dccbb80f11a8b1e81c18027e9bb6ff5e8431 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 24 Mar 2022 16:38:23 +0800 Subject: [PATCH 3/3] handle quit except --- source/libs/transport/src/transSrv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index b4052aea46..787c538f2a 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -838,6 +838,9 @@ void transSendResponse(const STransMsg* pMsg) { } SSrvConn* pConn = pMsg->handle; SWorkThrdObj* pThrd = pConn->hostThrd; + if (pThrd->quit) { + return; + } SSrvMsg* srvMsg = calloc(1, sizeof(SSrvMsg)); srvMsg->pConn = pConn;