diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index b65acc467215da77019235e5ec44a335b363e344..6d81499dbcf13cec4143ef79f3dd6735f70253c6 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -468,6 +468,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST); indexMultiTermQueryAdd(mtm, tm, qtype); ret = indexJsonSearch(arg->ivtIdx, mtm, output->result); + indexMultiTermQueryDestroy(mtm); } else { bool reverse; FilterFunc filterFunc = sifGetFilterFunc(qtype, &reverse); @@ -647,9 +648,8 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx)); if (params[0].status == SFLT_NOT_INDEX && (nParam > 1 && params[1].status == SFLT_NOT_INDEX)) { - for (int i = 0; i < nParam; i++) sifFreeParam(¶ms[i]); output->status = SFLT_NOT_INDEX; - return code; + goto _return; } // ugly code, refactor later diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c index 2aa8345e03bb3cec2a86c4240351dc86cb3ec9c7..5e787f9503ec13d920a9049e2f2b9d541fd1828b 100644 --- a/source/libs/index/src/indexFst.c +++ b/source/libs/index/src/indexFst.c @@ -1025,6 +1025,7 @@ void fstDestroy(Fst* fst) { } bool fstGet(Fst* fst, FstSlice* b, Output* out) { + int ret = false; FstNode* root = fstGetRoot(fst); Output tOut = 0; int32_t len; @@ -1037,7 +1038,7 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) { uint8_t inp = data[i]; Output res = 0; if (false == fstNodeFindInput(root, inp, &res)) { - return false; + goto _return; } FstTransition trn; @@ -1047,18 +1048,20 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) { taosArrayPush(nodes, &root); } if (!FST_NODE_IS_FINAL(root)) { - return false; + goto _return; } else { tOut = tOut + FST_NODE_FINAL_OUTPUT(root); + ret = true; } +_return: for (int32_t i = 0; i < taosArrayGetSize(nodes); i++) { FstNode** node = (FstNode**)taosArrayGet(nodes, i); fstNodeDestroy(*node); } taosArrayDestroy(nodes); *out = tOut; - return true; + return ret; } FStmBuilder* fstSearch(Fst* fst, FAutoCtx* ctx) { // refactor later @@ -1243,6 +1246,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { StreamState s = {.node = node, .trans = i, .out = {.null = false, .out = out}, .autState = autState}; taosArrayPush(sws->stack, &s); + taosMemoryFree(trans); return true; } } diff --git a/source/libs/index/src/indexFstDfa.c b/source/libs/index/src/indexFstDfa.c index 3a36010b42713995eabd55765b9756340ec6c779..8ce0ba1e69eb069cfe7b3c2009107d0eea5d5019 100644 --- a/source/libs/index/src/indexFstDfa.c +++ b/source/libs/index/src/indexFstDfa.c @@ -139,6 +139,7 @@ bool dfaBuilderCacheState(FstDfaBuilder *builder, FstSparseSet *set, uint32_t *r } } if (taosArrayGetSize(tinsts) == 0) { + taosArrayDestroy(tinsts); return false; } uint32_t *v = taosHashGet(builder->cache, &tinsts, sizeof(POINTER_BYTES)); diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index f3009c051b6905516ee64a506e4a67850396d46d..e746bb43034db6fee9fd1f27ae3cdc5979830b47 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -267,10 +267,12 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { uint64_t offset = *(uint64_t*)taosArrayGet(offsets, i); ret = tfileReaderLoadTableIds((TFileReader*)reader, offset, tr->total); if (ret != 0) { + taosArrayDestroy(offsets); indexError("failed to find target tablelist"); return TSDB_CODE_TDB_FILE_CORRUPTED; } } + taosArrayDestroy(offsets); return 0; } static int32_t tfSearchSuffix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { @@ -336,6 +338,7 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr, } stmStDestroy(st); stmBuilderDestroy(sb); + taosArrayDestroy(offsets); return TSDB_CODE_SUCCESS; } static int32_t tfSearchLessThan(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { @@ -379,6 +382,7 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { ", size: %d, time cost: %" PRIu64 "us", tem->suid, tem->colName, tem->colVal, offset, (int)taosArrayGetSize(tr->total), cost); } + taosMemoryFree(p); fstSliceDestroy(&key); return 0; } @@ -471,6 +475,9 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt } stmStDestroy(st); stmBuilderDestroy(sb); + taosArrayDestroy(offsets); + taosMemoryFree(p); + return TSDB_CODE_SUCCESS; } int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SIdxTRslt* tr) { @@ -898,9 +905,8 @@ static int tfileReaderLoadFst(TFileReader* reader) { int64_t ts = taosGetTimestampUs(); int32_t nread = ctx->readFrom(ctx, buf, fstSize, reader->header.fstOffset); int64_t cost = taosGetTimestampUs() - ts; - indexInfo("nread = %d, and fst offset=%d, fst size: %d, filename: %s, file size: %" PRId64 ", time cost: %" PRId64 - "us", - nread, reader->header.fstOffset, fstSize, ctx->file.buf, size, cost); + indexInfo("nread = %d, and fst offset=%d, fst size: %d, filename: %s, file size: %d, time cost: %" PRId64 "us", nread, + reader->header.fstOffset, fstSize, ctx->file.buf, size, cost); // we assuse fst size less than FST_MAX_SIZE assert(nread > 0 && nread <= fstSize); @@ -989,6 +995,7 @@ static SArray* tfileGetFileList(const char* path) { TdDirPtr pDir = taosOpenDir(path); if (NULL == pDir) { + taosArrayDestroy(files); return NULL; } TdDirEntryPtr pDirEntry; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 191011111d289f2d261f3ac21299c1e2a4493836..ff4fae3de87879940317c6ab78af14f84e0dc8c2 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1347,7 +1347,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { EPSET_FORWARD_INUSE(&pCtx->epSet); } else { if (tDeserializeSEpSet(pResp->pCont, pResp->contLen, &pCtx->epSet) < 0) { - tError("%s conn %p failed to deserialize epset", CONN_GET_INST_LABEL(pConn)); + tError("%s conn %p failed to deserialize epset", CONN_GET_INST_LABEL(pConn), pConn); } } addConnToPool(pThrd->pool, pConn); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index ae9f3155b42a0c8e439693ebb1604adedc297a26..e86314d4bd7f4dc7b15881ac063ddf2a24965ba4 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -509,7 +509,7 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) { if (heapSize(queue->heap) != 0) { HeapNode* minNode = heapMin(queue->heap); - if (minNode != NULL) return; + if (minNode == NULL) return; uint64_t now = taosGetTimestampMs(); SDelayTask* task = container_of(minNode, SDelayTask, node); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 70a47fe079ed2d2fbd4638a3273f69c75bb8d60a..c63f8f398b1c6d8ebb64992c8aeaefe05d010211 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -284,7 +284,7 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { } return; } else { - tError("%s conn %p read invalid packet, exceed limit, received from %s, local info:", transLabel(pTransInst), + tError("%s conn %p read invalid packet, exceed limit, received from %s, local info:%s", transLabel(pTransInst), conn, conn->dst, conn->src); destroyConn(conn, true); return; @@ -952,10 +952,10 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, #ifdef WINDOWS char pipeName[64]; - snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%p-" PRIu64, taosSafeRand(), GetCurrentProcessId()); + snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%d-%" PRIu64, taosSafeRand(), GetCurrentProcessId()); #else char pipeName[PATH_MAX] = {0}; - snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08X-" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(), + snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08d-%" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(), taosGetSelfPthreadId()); #endif ret = uv_pipe_bind(&srv->pipeListen, pipeName); diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index b34d071773591600e06adc9b08873a89b7e2e1b4..c1e02b48aa047e1043a41820ed77b6626e090aa2 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -801,7 +801,6 @@ TdSocketServerPtr taosOpenTcpServerSocket(uint32_t ip, uint16_t port) { if (taosKeepTcpAlive(pSocket) < 0) { // printf("failed to set tcp server keep-alive option, 0x%x:%hu(%s)", ip, port, strerror(errno)); - taosCloseSocket(&pSocket); return NULL; }