From c35513a507d7ee839da979f15fc24dd58eba86bd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 21 Aug 2024 19:19:39 +0800 Subject: [PATCH] fix mem problem --- include/os/osFile.h | 17 +++++++++-------- source/libs/transport/src/transSvr.c | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/os/osFile.h b/include/os/osFile.h index a56c54b086..536dee268a 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -130,14 +130,15 @@ int taosSetAutoDelFile(char *path); bool lastErrorIsFileNotExist(); #ifdef BUILD_WITH_RAND_ERR -#define STUB_RAND_NETWORK_ERR(status) \ - do { \ - if (tsEnableRandErr && (tsRandErrScope & RAND_ERR_NETWORK)) { \ - uint32_t r = taosRand() % tsRandErrDivisor; \ - if ((r + 1) <= tsRandErrChance) { \ - status = TSDB_CODE_RPC_NETWORK_UNAVAIL; \ - } \ - } \ +#define STUB_RAND_NETWORK_ERR(ret) \ + do { \ + if (tsEnableRandErr && (tsRandErrScope & RAND_ERR_NETWORK)) { \ + uint32_t r = taosRand() % tsRandErrDivisor; \ + if ((r + 1) <= tsRandErrChance) { \ + ret = TSDB_CODE_RPC_NETWORK_UNAVAIL; \ + uError("random network error: %s, %s", tstrerror(ret), __func__); \ + } \ + } \ while (0) #else #define STUB_RAND_NETWORK_ERR(status) diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index e03d5ddc34..a3f8c65cba 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -1191,6 +1191,7 @@ void* transWorkerThread(void* arg) { static FORCE_INLINE SSvrConn* createConn(void* hThrd) { int32_t code = 0; SWorkThrd* pThrd = hThrd; + STrans* pTransInst = pThrd->pTransInst; SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn)); if (pConn == NULL) { @@ -1232,7 +1233,6 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd) { TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); } - STrans* pTransInst = pThrd->pTransInst; pConn->refId = exh->refId; QUEUE_INIT(&exh->q); transRefSrvHandle(pConn);