diff --git a/docs/examples/c/multi_bind_example.c b/docs/examples/c/multi_bind_example.c index 3d0bd3ccef..0134899a1d 100644 --- a/docs/examples/c/multi_bind_example.c +++ b/docs/examples/c/multi_bind_example.c @@ -33,7 +33,7 @@ void executeSQL(TAOS *taos, const char *sql) { void checkErrorCode(TAOS_STMT *stmt, int code, const char *msg) { if (code != 0) { printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); exit(EXIT_FAILURE); } } @@ -123,7 +123,7 @@ void insertData(TAOS *taos) { int affectedRows = taos_stmt_affected_rows(stmt); printf("successfully inserted %d rows\n", affectedRows); // close - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); } int main() { diff --git a/docs/examples/c/stmt_example.c b/docs/examples/c/stmt_example.c index 290a6bee66..3b9efe49d7 100644 --- a/docs/examples/c/stmt_example.c +++ b/docs/examples/c/stmt_example.c @@ -33,7 +33,7 @@ void executeSQL(TAOS *taos, const char *sql) { void checkErrorCode(TAOS_STMT *stmt, int code, const char* msg) { if (code != 0) { printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); exit(EXIT_FAILURE); } } @@ -119,7 +119,7 @@ void insertData(TAOS *taos) { int affectedRows = taos_stmt_affected_rows(stmt); printf("successfully inserted %d rows\n", affectedRows); // close - taos_stmt_close(stmt); + (void)taos_stmt_close(stmt); } int main() { diff --git a/docs/examples/c/subscribe_demo.c b/docs/examples/c/subscribe_demo.c deleted file mode 100644 index 2fe62c24eb..0000000000 --- a/docs/examples/c/subscribe_demo.c +++ /dev/null @@ -1,66 +0,0 @@ -// A simple demo for asynchronous subscription. -// compile with: -// gcc -o subscribe_demo subscribe_demo.c -ltaos - -#include -#include -#include -#include - -int nTotalRows; - -/** - * @brief callback function of subscription. - * - * @param tsub - * @param res - * @param param. the additional parameter passed to taos_subscribe - * @param code. error code - */ -void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) { - if (code != 0) { - printf("error: %d\n", code); - exit(EXIT_FAILURE); - } - - TAOS_ROW row = NULL; - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - int nRows = 0; - - while ((row = taos_fetch_row(res))) { - char buf[4096] = {0}; - taos_print_row(buf, row, fields, num_fields); - puts(buf); - nRows++; - } - - nTotalRows += nRows; - printf("%d rows consumed.\n", nRows); -} - -int main() { - TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); - if (taos == NULL) { - printf("failed to connect to server\n"); - exit(EXIT_FAILURE); - } - - int restart = 1; // if the topic already exists, where to subscribe from the begin. - const char* topic = "topic-meter-current-bg-10"; - const char* sql = "select * from power.meters where current > 10"; - void* param = NULL; // additional parameter. - int interval = 2000; // consumption interval in microseconds. - TAOS_SUB* tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, NULL, interval); - - // wait for insert from others process. you can open TDengine CLI to insert some records for test. - - getchar(); // press Enter to stop - - printf("total rows consumed: %d\n", nTotalRows); - int keep = 0; // whether to keep subscribe process - taos_unsubscribe(tsub, keep); - - taos_close(taos); - taos_cleanup(); -} diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 75a67ea484..4eb64785df 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1075,10 +1075,10 @@ typedef struct { SUpdateUserIpWhite* pUserIpWhite; } SUpdateIpWhite; -int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); -int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); -void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq); -SUpdateIpWhite* cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq); +int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); +int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq); +void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq); +int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq, SUpdateIpWhite** pUpdate); typedef struct { int64_t ipWhiteVer; @@ -3639,9 +3639,9 @@ static FORCE_INLINE void tqOffsetResetToLog(STqOffsetVal* pOffsetVal, int64_t ve int32_t tEncodeSTqOffsetVal(SEncoder* pEncoder, const STqOffsetVal* pOffsetVal); int32_t tDecodeSTqOffsetVal(SDecoder* pDecoder, STqOffsetVal* pOffsetVal); -int32_t tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); +void tFormatOffset(char* buf, int32_t maxLen, const STqOffsetVal* pVal); bool tOffsetEqual(const STqOffsetVal* pLeft, const STqOffsetVal* pRight); -int32_t tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); +void tOffsetCopy(STqOffsetVal* pLeft, const STqOffsetVal* pRight); void tOffsetDestroy(void* pVal); typedef struct { diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index b7a459f957..6c0d04354a 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -164,13 +164,13 @@ int rpcRegisterBrokenLinkArg(SRpcMsg *msg); int rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock // These functions will not be called in the child process -int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx); -int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); -int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated, - int32_t timeoutMs); -int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn); -void *rpcAllocHandle(); -void rpcSetIpWhite(void *thandl, void *arg); +int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx); +int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp); +int rpcSendRecvWithTimeout(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp, int8_t *epUpdated, + int32_t timeoutMs); +int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn); +void *rpcAllocHandle(); +int32_t rpcSetIpWhite(void *thandl, void *arg); int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 5ec18daab7..7ff3e500cf 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -90,6 +90,8 @@ int32_t taosGetErrSize(); #define TSDB_CODE_RPC_NETWORK_ERROR TAOS_DEF_ERROR_CODE(0, 0x0023) #define TSDB_CODE_RPC_NETWORK_BUSY TAOS_DEF_ERROR_CODE(0, 0x0024) #define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025) +#define TSDB_CODE_RPC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0026) +#define TSDB_CODE_RPC_ASYNC_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0027) diff --git a/include/util/tarray2.h b/include/util/tarray2.h index ce24a1d2ce..0781b3ac4e 100644 --- a/include/util/tarray2.h +++ b/include/util/tarray2.h @@ -116,7 +116,7 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int if ((cb) && (a)->size > 0) { \ TArray2Cb cb_ = (TArray2Cb)(cb); \ for (int32_t i = 0; i < (a)->size; ++i) { \ - cb_((a)->data + i); \ + (void)cb_((a)->data + i); \ } \ } \ (a)->size = 0; \ diff --git a/include/util/tbuffer.h b/include/util/tbuffer.h index 094d0e37ba..2c77ea2e30 100644 --- a/include/util/tbuffer.h +++ b/include/util/tbuffer.h @@ -27,9 +27,9 @@ typedef struct SBufferReader SBufferReader; // SBuffer #define BUFFER_INITIALIZER ((SBuffer){0, 0, NULL}) -static int32_t tBufferInit(SBuffer *buffer); -static int32_t tBufferDestroy(SBuffer *buffer); -static int32_t tBufferClear(SBuffer *buffer); +static void tBufferInit(SBuffer *buffer); +static void tBufferDestroy(SBuffer *buffer); +static void tBufferClear(SBuffer *buffer); static int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity); static int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size); static int32_t tBufferPutAt(SBuffer *buffer, uint32_t offset, const void *data, uint32_t size); diff --git a/include/util/tbuffer.inc b/include/util/tbuffer.inc index 595c1e0827..39090fb7fa 100644 --- a/include/util/tbuffer.inc +++ b/include/util/tbuffer.inc @@ -29,27 +29,22 @@ struct SBufferReader { }; // SBuffer -static FORCE_INLINE int32_t tBufferInit(SBuffer *buffer) { +static FORCE_INLINE void tBufferInit(SBuffer *buffer) { buffer->size = 0; buffer->capacity = 0; buffer->data = NULL; - return 0; } -static FORCE_INLINE int32_t tBufferDestroy(SBuffer *buffer) { +static FORCE_INLINE void tBufferDestroy(SBuffer *buffer) { buffer->size = 0; buffer->capacity = 0; if (buffer->data) { taosMemoryFree(buffer->data); buffer->data = NULL; } - return 0; } -static FORCE_INLINE int32_t tBufferClear(SBuffer *buffer) { - buffer->size = 0; - return 0; -} +static FORCE_INLINE void tBufferClear(SBuffer *buffer) { buffer->size = 0; } static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capacity) { if (buffer->capacity < capacity) { diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index f4ecc6929b..2258a4bc8c 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -555,7 +555,6 @@ int32_t createRequest(uint64_t connId, int32_t type, int64_t reqid, SRequestObj (*pRequest)->pDb = getDbOfConnection(pTscObj); (*pRequest)->pTscObj = pTscObj; (*pRequest)->inCallback = false; - (*pRequest)->msgBuf = taosMemoryCalloc(1, ERROR_MSG_BUF_DEFAULT_SIZE); if (NULL == (*pRequest)->msgBuf) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -917,17 +916,17 @@ void taos_init_imp(void) { if (tscDbg.memEnable) { int32_t code = taosMemoryDbgInit(); if (code) { - printf("failed to init memory dbg, error:%s\n", tstrerror(code)); + (void)printf("failed to init memory dbg, error:%s\n", tstrerror(code)); } else { tsAsyncLog = false; - printf("memory dbg enabled\n"); + (void)printf("memory dbg enabled\n"); } } #endif // In the APIs of other program language, taos_cleanup is not available yet. // So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning. - atexit(taos_cleanup); + (void)atexit(taos_cleanup); errno = TSDB_CODE_SUCCESS; taosSeedRand(taosGetTimestampSec()); @@ -950,7 +949,7 @@ void taos_init_imp(void) { (void)snprintf(logDirName, 64, "taoslog"); #endif if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { - printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir); + (void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir); tscInitRes = -1; return; } @@ -994,7 +993,7 @@ void taos_init_imp(void) { } int taos_init() { - taosThreadOnce(&tscinit, taos_init_imp); + (void)taosThreadOnce(&tscinit, taos_init_imp); return tscInitRes; } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 0b7de322f5..a174ae4b13 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -1330,6 +1330,10 @@ static void *hbThreadFunc(void *param) { continue; } int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq); + if (tlen == -1) { + tFreeClientHbBatchReq(pReq); + break; + } void *buf = taosMemoryMalloc(tlen); if (buf == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -1338,7 +1342,11 @@ static void *hbThreadFunc(void *param) { break; } - tSerializeSClientHbBatchReq(buf, tlen, pReq); + if (tSerializeSClientHbBatchReq(buf, tlen, pReq) == -1) { + tFreeClientHbBatchReq(pReq); + taosMemoryFree(buf); + break; + } SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (pInfo == NULL) { @@ -1361,10 +1369,12 @@ static void *hbThreadFunc(void *param) { SAppInstInfo *pAppInstInfo = pAppHbMgr->pAppInstInfo; int64_t transporterId = 0; SEpSet epSet = getEpSet_s(&pAppInstInfo->mgmtEp); - asyncSendMsgToServer(pAppInstInfo->pTransporter, &epSet, &transporterId, pInfo); + if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pAppInstInfo->pTransporter, &epSet, &transporterId, pInfo)) { + tscWarn("failed to async send msg to server"); + } tFreeClientHbBatchReq(pReq); // hbClearReqInfo(pAppHbMgr); - atomic_add_fetch_32(&pAppHbMgr->reportCnt, 1); + (void)atomic_add_fetch_32(&pAppHbMgr->reportCnt, 1); } if (TSDB_CODE_SUCCESS != taosThreadMutexUnlock(&clientHbMgr.lock)) { @@ -1629,7 +1639,7 @@ void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) { SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); if (pReq) { tFreeClientHbReq(pReq); - taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); + (void)taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey)); taosHashRelease(pAppHbMgr->activeInfo, pReq); (void)atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1); } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 0c1924c8d8..a458edcad9 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -332,7 +332,6 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) { int64_t transporterId = 0; TSC_ERR_RET(asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &pMsgInfo->epSet, &transporterId, pSendMsg)); - (void)tsem_wait(&pRequest->body.rspSem); return TSDB_CODE_SUCCESS; } @@ -1083,7 +1082,7 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) { SRequestObj* pNextReq = acquireRequest(pRequest->relation.nextRefId); if (pNextReq) { continuePostSubQuery(pNextReq, pBlock); - releaseRequest(pRequest->relation.nextRefId); + (void)releaseRequest(pRequest->relation.nextRefId); } else { tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self, pRequest->relation.nextRefId, pRequest->requestId); @@ -2545,7 +2544,7 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2, } char dbFName[TSDB_DB_FNAME_LEN]; - sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName); + (void)sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName); STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName)); if (pDb) { diff --git a/source/client/src/clientJniConnector.c b/source/client/src/clientJniConnector.c index 4a200179f9..d783c6d8e4 100644 --- a/source/client/src/clientJniConnector.c +++ b/source/client/src/clientJniConnector.c @@ -484,7 +484,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData (*env)->SetIntField(env, metadataObj, g_metadataColindexField, i); jstring metadataObjColname = (*env)->NewStringUTF(env, fields[i].name); (*env)->SetObjectField(env, metadataObj, g_metadataColnameField, metadataObjColname); - (*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj); + (void)(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj); } } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index ae494301d2..01a4fd5640 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -42,7 +42,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) { for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) { if (i % 1000 == 0) { tscInfo("haven't acquire lock after spin %d times.", i); - sched_yield(); + (void)sched_yield(); } } @@ -754,7 +754,7 @@ bool taos_is_update_query(TAOS_RES *res) { return taos_num_fields(res) == 0; } int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { int32_t numOfRows = 0; - /*int32_t code = */ taos_fetch_block_s(res, &numOfRows, rows); + /*int32_t code = */ terrno = taos_fetch_block_s(res, &numOfRows, rows); return numOfRows; } diff --git a/source/client/src/clientMonitor.c b/source/client/src/clientMonitor.c index e3b073dbc8..40cea644fd 100644 --- a/source/client/src/clientMonitor.c +++ b/source/client/src/clientMonitor.c @@ -21,13 +21,10 @@ SHashObj* monitorSlowLogHash; char tmpSlowLogPath[PATH_MAX] = {0}; static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) { - if (tsTempDir == NULL) { - return -1; - } int ret = snprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir); if (ret < 0) { tscError("failed to get tmp path ret:%d", ret); - return ret; + return TSDB_CODE_TSC_INTERNAL_ERROR; } return 0; } @@ -71,10 +68,9 @@ static void destroyMonitorClient(void* data) { if (pMonitor == NULL) { return; } - taosTmrStopA(&pMonitor->timer); + (void)taosTmrStopA(&pMonitor->timer); taosHashCleanup(pMonitor->counters); - taos_collector_registry_destroy(pMonitor->registry); - // taos_collector_destroy(pMonitor->colector); + (void)taos_collector_registry_destroy(pMonitor->registry); taosMemoryFree(pMonitor); } @@ -142,15 +138,17 @@ static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITO void* buf = taosMemoryMalloc(tlen); if (buf == NULL) { tscError("sendReport failed, out of memory, len:%d", tlen); - terrno = TSDB_CODE_OUT_OF_MEMORY; goto FAILED; } - tSerializeSStatisReq(buf, tlen, &sStatisReq); + tlen = tSerializeSStatisReq(buf, tlen, &sStatisReq); + if (tlen < 0) { + taosMemoryFree(buf); + goto FAILED; + } SMsgSendInfo* pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (pInfo == NULL) { tscError("sendReport failed, out of memory send info"); - terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(buf); goto FAILED; } @@ -168,12 +166,12 @@ static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITO FAILED: monitorFreeSlowLogDataEx(param); - return -1; + return TAOS_GET_TERRNO(TSDB_CODE_TSC_INTERNAL_ERROR); } static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) { char ts[50] = {0}; - sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI)); + (void)sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI)); char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL); if (NULL == pCont) { tscError("generateClusterReport failed, get null content."); @@ -181,7 +179,7 @@ static void generateClusterReport(taos_collector_registry_t* registry, void* pTr } if (strlen(pCont) != 0 && sendReport(pTransporter, epSet, pCont, MONITOR_TYPE_COUNTER, NULL) == 0) { - taos_collector_registry_clear_batch(registry); + (void)taos_collector_registry_clear_batch(registry); } taosMemoryFreeClear(pCont); } @@ -202,7 +200,7 @@ static void reportSendProcess(void* param, void* tmrId) { SEpSet ep = getEpSet_s(&pInst->mgmtEp); generateClusterReport(pMonitor->registry, pInst->pTransporter, &ep); - taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId); + (void)taosTmrReset(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId); taosRUnLockLatch(&monitorLock); } @@ -250,14 +248,13 @@ void monitorCreateClient(int64_t clusterId) { goto fail; } - taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector); + (void)taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector); pMonitor->counters = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (pMonitor->counters == NULL) { tscError("failed to create monitor counters"); goto fail; } - // taosHashSetFreeFp(pMonitor->counters, destroyCounter); if (taosHashPut(monitorCounterHash, &clusterId, LONG_BYTES, &pMonitor, POINTER_BYTES) != 0) { tscError("failed to put monitor client to hash"); @@ -300,10 +297,14 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* taos_counter_t* newCounter = taos_counter_new(name, help, label_key_count, label_keys); if (newCounter == NULL) return; MonitorClient* pMonitor = *ppMonitor; - taos_collector_add_metric(pMonitor->colector, newCounter); + if (taos_collector_add_metric(pMonitor->colector, newCounter) != 0){ + tscError("failed to add metric to collector"); + (void)taos_counter_destroy(newCounter); + goto end; +} if (taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0) { tscError("failed to put counter to monitor"); - taos_counter_destroy(newCounter); + (void)taos_counter_destroy(newCounter); goto end; } tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name, @@ -332,7 +333,10 @@ void monitorCounterInc(int64_t clusterId, const char* counterName, const char** tscError("monitorCounterInc not found pCounter %" PRIx64 ":%s.", clusterId, counterName); goto end; } - taos_counter_inc(*ppCounter, label_values); + if (taos_counter_inc(*ppCounter, label_values) != 0){ + tscError("monitorCounterInc failed to inc %" PRIx64 ":%s.", clusterId, counterName); + goto end; + } tscDebug("[monitor] monitorCounterInc %" PRIx64 "(%p):%s", pMonitor->clusterId, pMonitor, counterName); end: @@ -360,24 +364,23 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpP tscInfo("[monitor] create slow log file:%s", path); pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC); if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - tscError("failed to open file:%s since %s", path, terrstr()); + tscError("failed to open file:%s since %d", path, errno); return; } SlowLogClient* pClient = taosMemoryCalloc(1, sizeof(SlowLogClient)); if (pClient == NULL) { tscError("failed to allocate memory for slow log client"); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return; } pClient->lastCheckTime = taosGetMonoTimestampMs(); - strcpy(pClient->path, path); + (void)strcpy(pClient->path, path); pClient->offset = 0; pClient->pFile = pFile; if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) { tscError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); taosMemoryFree(pClient); return; } @@ -423,7 +426,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) { return NULL; } char* buf = pCont; - strcat(buf++, "["); + (void)strcat(buf++, "["); int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX); if (readSize <= 0) { if (readSize < 0) { @@ -454,7 +457,7 @@ static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) { static int64_t getFileSize(char* path) { int64_t fileSize = 0; if (taosStatFile(path, &fileSize, NULL, NULL) < 0) { - return -1; + return TSDB_CODE_TSC_INTERNAL_ERROR; } return fileSize; @@ -464,13 +467,13 @@ static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64 char* fileName, void* pTransporter, SEpSet* epSet) { if (data == NULL) { taosMemoryFree(fileName); - return -1; + return TSDB_CODE_INVALID_PARA; } MonitorSlowLogData* pParam = taosMemoryMalloc(sizeof(MonitorSlowLogData)); if (pParam == NULL) { taosMemoryFree(data); taosMemoryFree(fileName); - return -1; + return terrno; } pParam->data = data; pParam->offset = offset; @@ -486,7 +489,7 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs SAppInstInfo* pInst = getAppInstByClusterId(clusterId); if (pInst == NULL) { tscError("failed to get app instance by clusterId:%" PRId64, clusterId); - return -1; + return terrno; } SEpSet ep = getEpSet_s(&pInst->mgmtEp); char* data = readFile(pFile, offset, size); @@ -495,13 +498,20 @@ static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offs } static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, TdFilePtr pFile, int64_t offset) { + if (fileName == NULL){ + return; + } int64_t size = getFileSize(*fileName); if (size <= offset) { processFileInTheEnd(pFile, *fileName); tscDebug("[monitor] monitorSendSlowLogAtBeginning delete file:%s", *fileName); } else { int32_t code = monitorReadSend(clusterId, pFile, &offset, size, SLOW_LOG_READ_BEGINNIG, *fileName); - tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log clusterId:%" PRId64 ",ret:%d", clusterId, code); + if (code == 0){ + tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log succ, clusterId:%" PRId64, clusterId); + }else{ + tscError("[monitor] monitorSendSlowLogAtBeginning send slow log failed, clusterId:%" PRId64 ",ret:%d", clusterId, code); + } *fileName = NULL; } } @@ -509,10 +519,12 @@ static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, Td static void monitorSendSlowLogAtRunning(int64_t clusterId) { void* tmp = taosHashGet(monitorSlowLogHash, &clusterId, LONG_BYTES); if (tmp == NULL) { + tscError("failed to get slow log client by clusterId:%" PRId64, clusterId); return; } SlowLogClient* pClient = (*(SlowLogClient**)tmp); if (pClient == NULL) { + tscError("failed to get slow log client by clusterId:%" PRId64, clusterId); return; } int64_t size = getFileSize(pClient->path); @@ -574,14 +586,16 @@ static void monitorSendAllSlowLogAtQuit() { } static void processFileRemoved(SlowLogClient* pClient) { - taosUnLockFile(pClient->pFile); - taosCloseFile(&(pClient->pFile)); + if (taosUnLockFile(pClient->pFile) != 0) { + tscError("failed to unlock file:%s since %d", pClient->path, errno); + return; + } + (void)taosCloseFile(&(pClient->pFile)); TdFilePtr pFile = taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC); if (pFile == NULL) { - terrno = TAOS_SYSTEM_ERROR(errno); - tscError("failed to open file:%s since %s", pClient->path, terrstr()); + tscError("failed to open file:%s since %d", pClient->path, errno); } else { pClient->pFile = pFile; } @@ -594,7 +608,7 @@ static void monitorSendAllSlowLog() { int64_t* clusterId = (int64_t*)taosHashGetKey(pIter, NULL); SAppInstInfo* pInst = getAppInstByClusterId(*clusterId); SlowLogClient* pClient = (*(SlowLogClient**)pIter); - if (pClient == NULL) { + if (pClient == NULL || pInst == NULL) { taosHashCancelIterate(monitorSlowLogHash, pIter); return; } @@ -604,7 +618,7 @@ static void monitorSendAllSlowLog() { continue; } - if (pInst != NULL && pClient->offset == 0) { + if (pClient->offset == 0) { int64_t size = getFileSize(pClient->path); if (size <= 0) { if (size < 0) { @@ -657,7 +671,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) { } char filename[PATH_MAX] = {0}; - snprintf(filename, sizeof(filename), "%s%s", tmpPath, name); + (void)snprintf(filename, sizeof(filename), "%s%s", tmpPath, name); TdFilePtr pFile = taosOpenFile(filename, TD_FILE_READ | TD_FILE_WRITE); if (pFile == NULL) { tscError("failed to open file:%s since %s", filename, terrstr()); @@ -665,7 +679,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) { } if (taosLockFile(pFile) < 0) { tscError("failed to lock file:%s since %s, maybe used by other process", filename, terrstr()); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); continue; } char* tmp = taosStrdup(filename); @@ -673,7 +687,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) { taosMemoryFree(tmp); } - taosCloseDir(&pDir); + (void)taosCloseDir(&pDir); } static void* monitorThreadFunc(void* param) { @@ -707,7 +721,7 @@ static void* monitorThreadFunc(void* param) { } MonitorSlowLogData* slowLogData = NULL; - taosReadQitem(monitorQueue, (void**)&slowLogData); + (void)taosReadQitem(monitorQueue, (void**)&slowLogData); if (slowLogData != NULL) { if (slowLogData->type == SLOW_LOG_READ_BEGINNIG) { if (slowLogData->pFile != NULL) { @@ -735,7 +749,7 @@ static void* monitorThreadFunc(void* param) { if (quitCnt == 0) { monitorSendAllSlowLog(); } - tsem2_timewait(&monitorSem, 100); + (void)tsem2_timewait(&monitorSem, 100); } atomic_store_32(&slowLogFlag, -2); return NULL; @@ -743,15 +757,22 @@ static void* monitorThreadFunc(void* param) { static int32_t tscMonitortInit() { TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + if (taosThreadAttrInit(&thAttr) != 0) { + tscError("failed to init thread attr since %s", strerror(errno)); + return TSDB_CODE_TSC_INTERNAL_ERROR; + } + if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) { + tscError("failed to set thread attr since %s", strerror(errno)); + return TSDB_CODE_TSC_INTERNAL_ERROR; + } + TdThread monitorThread; if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) { tscError("failed to create monitor thread since %s", strerror(errno)); - return -1; + return TSDB_CODE_TSC_INTERNAL_ERROR; } - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); return 0; } @@ -767,15 +788,14 @@ static void tscMonitorStop() { } int32_t monitorInit() { - int32_t code; + int32_t code = 0; tscInfo("[monitor] tscMonitor init"); monitorCounterHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); if (monitorCounterHash == NULL) { tscError("failed to create monitorCounterHash"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } taosHashSetFreeFp(monitorCounterHash, destroyMonitorClient); @@ -783,46 +803,39 @@ int32_t monitorInit() { (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); if (monitorSlowLogHash == NULL) { tscError("failed to create monitorSlowLogHash"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } taosHashSetFreeFp(monitorSlowLogHash, destroySlowLogClient); monitorTimer = taosTmrInit(0, 0, 0, "MONITOR"); if (monitorTimer == NULL) { tscError("failed to create monitor timer"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } - if (getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath)) < 0) { - terrno = TSDB_CODE_TSC_INTERNAL_ERROR; - return -1; + code = getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath)); + if (code != 0) { + return code; } if (taosMulModeMkDir(tmpSlowLogPath, 0777, true) != 0) { tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr()); - return terrno; + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); } if (tsem2_init(&monitorSem, 0, 0) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); tscError("sem init error since %s", terrstr()); - return -1; + return TAOS_SYSTEM_ERROR(errno); } code = taosOpenQueue(&monitorQueue); if (code) { - terrno = code; tscError("open queue error since %s", terrstr()); - return -1; + return TAOS_GET_TERRNO(code); } taosInitRWLatch(&monitorLock); - if (tscMonitortInit() != 0) { - return -1; - } - return 0; + return tscMonitortInit(); } void monitorClose() { @@ -838,13 +851,13 @@ void monitorClose() { taosHashCleanup(monitorSlowLogHash); taosTmrCleanUp(monitorTimer); taosCloseQueue(monitorQueue); - tsem2_destroy(&monitorSem); + (void)tsem2_destroy(&monitorSem); taosWUnLockLatch(&monitorLock); } int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) { - int32_t code; - MonitorSlowLogData* slowLogData; + int32_t code = 0; + MonitorSlowLogData* slowLogData = NULL; if (atomic_load_32(&slowLogFlag) == -2) { tscError("[monitor] slow log thread is exiting"); @@ -854,13 +867,13 @@ int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) { code = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0, (void**)&slowLogData); if (code) { tscError("[monitor] failed to allocate slow log data"); - return terrno = code; + return code; } *slowLogData = data; tscDebug("[monitor] write slow log to queue, clusterId:%" PRIx64 " type:%s, data:%s", slowLogData->clusterId, queueTypeStr[slowLogData->type], slowLogData->data); if (taosWriteQitem(monitorQueue, slowLogData) == 0) { - tsem2_post(&monitorSem); + (void)tsem2_post(&monitorSem); } else { monitorFreeSlowLogData(slowLogData); taosFreeQitem(slowLogData); diff --git a/source/client/src/clientMonitorSlow.c b/source/client/src/clientMonitorSlow.c index 192792f43e..5945f28884 100644 --- a/source/client/src/clientMonitorSlow.c +++ b/source/client/src/clientMonitorSlow.c @@ -69,7 +69,7 @@ void slowQueryLog(int64_t rid, bool killed, int32_t code, int32_t cost) { } else { clientSlowQueryLog(pTscObj->pAppInfo->clusterId, pTscObj->user, result, cost); } - releaseTscObj(rid); + (void)releaseTscObj(rid); } else { tscLog("slowQueryLog, not found rid"); } diff --git a/source/client/src/clientMonitorSql.c b/source/client/src/clientMonitorSql.c index 19d5b7506e..2556cf123a 100644 --- a/source/client/src/clientMonitorSql.c +++ b/source/client/src/clientMonitorSql.c @@ -65,7 +65,7 @@ void sqlReqLog(int64_t rid, bool killed, int32_t code, int8_t type) { } else { clientSQLReqLog(pTscObj->pAppInfo->clusterId, pTscObj->user, result, type); } - releaseTscObj(rid); + (void)releaseTscObj(rid); } else { tscLog("sqlReqLog, not found rid"); } diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index d587deffc5..cc1ed7f3fa 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -40,7 +40,9 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) { - removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)); + if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0){ + tscError("failed to remove meta data for table"); + } } taosMemoryFree(pMsg->pEpSet); @@ -48,7 +50,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) { if (pRequest->body.queryFp != NULL) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } @@ -61,7 +63,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } @@ -70,7 +72,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { if (NULL == pTscObj->pAppInfo) { code = TSDB_CODE_TSC_DISCONNECTED; setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } @@ -78,14 +80,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { if (tDeserializeSConnectRsp(pMsg->pData, pMsg->len, &connectRsp) != 0) { code = TSDB_CODE_TSC_INVALID_VERSION; setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) { tscError("version not compatible. client version: %s, server version: %s", version, connectRsp.sVer); setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } @@ -95,14 +97,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { code = TSDB_CODE_TIME_UNSYNCED; tscError("time diff:%ds is too big", delta); setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } if (connectRsp.epSet.numOfEps == 0) { code = TSDB_CODE_APP_ERROR; setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } @@ -111,8 +113,10 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { SEpSet srcEpSet = getEpSet_s(&pTscObj->pAppInfo->mgmtEp); SEpSet dstEpSet = connectRsp.epSet; if (srcEpSet.numOfEps == 1) { - rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn, - dstEpSet.eps[dstEpSet.inUse].fqdn); + if (rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn, + dstEpSet.eps[dstEpSet.inUse].fqdn) != 0){ + tscError("failed to set default addr for rpc"); + } updateEpSet = 0; } } @@ -158,33 +162,35 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { MonitorSlowLogData data = {0}; data.clusterId = pTscObj->pAppInfo->clusterId; data.type = SLOW_LOG_READ_BEGINNIG; - monitorPutData2MonitorQueue(data); + (void)monitorPutData2MonitorQueue(data); // ignore monitorClientSlowQueryInit(connectRsp.clusterId); monitorClientSQLReqInit(connectRsp.clusterId); } } - taosThreadMutexLock(&clientHbMgr.lock); + (void)taosThreadMutexLock(&clientHbMgr.lock); SAppHbMgr* pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx); if (pAppHbMgr) { - hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType); + if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0){ + tscError("0x%" PRIx64 " failed to register conn to hbMgr", pRequest->requestId); + } } else { - taosThreadMutexUnlock(&clientHbMgr.lock); + (void)taosThreadMutexUnlock(&clientHbMgr.lock); code = TSDB_CODE_TSC_DISCONNECTED; setErrno(pRequest, code); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); goto End; } - taosThreadMutexUnlock(&clientHbMgr.lock); + (void)taosThreadMutexUnlock(&clientHbMgr.lock); tscDebug("0x%" PRIx64 " clusterId:%" PRId64 ", totalConn:%" PRId64, pRequest->requestId, connectRsp.clusterId, pTscObj->pAppInfo->numOfConns); - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); End: if (pRequest) { - releaseRequest(pRequest->self); + (void)releaseRequest(pRequest->self); } taosMemoryFree(param); @@ -216,7 +222,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); } else { struct SCatalog* pCatalog = NULL; - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (TSDB_CODE_SUCCESS == code) { STscObj* pTscObj = pRequest->pTscObj; @@ -225,28 +231,33 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) { .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; char dbFName[TSDB_DB_FNAME_LEN]; - snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB); - catalogRefreshDBVgInfo(pCatalog, &conn, dbFName); - snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB); - catalogRefreshDBVgInfo(pCatalog, &conn, dbFName); + (void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB); + if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){ + tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId); + } + (void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB); + if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){ + tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId); + } } } if (pRequest->body.queryFp) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { SRequestObj* pRequest = param; - if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code || TSDB_CODE_MND_DB_IN_DROPPING == code) { SUseDbRsp usedbRsp = {0}; - tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){ + tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId); + } struct SCatalog* pCatalog = NULL; if (usedbRsp.vgVersion >= 0) { // cached in local @@ -256,10 +267,12 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId, tstrerror(code1)); } else { - catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid); + if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0){ + tscError("0x%" PRIx64 "catalogRemoveDB failed, db:%s, uid:%" PRId64, pRequest->requestId, usedbRsp.db, + usedbRsp.uid); + } } } - tFreeSUsedbRsp(&usedbRsp); } @@ -272,14 +285,16 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { doRequestCallback(pRequest, pRequest->code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } SUseDbRsp usedbRsp = {0}; - tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){ + tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId); + } if (strlen(usedbRsp.db) == 0) { if (usedbRsp.errCode != 0) { @@ -292,6 +307,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tscTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum); for (int32_t i = 0; i < usedbRsp.vgNum; ++i) { SVgroupInfo* pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i); + if (pInfo == NULL){ + continue; + } tscTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse); for (int32_t j = 0; j < pInfo->epSet.numOfEps; ++j) { tscTrace("vgId:%d, index:%d epset:%s:%u", pInfo->vgId, j, pInfo->epSet.eps[j].fqdn, pInfo->epSet.eps[j].port); @@ -299,11 +317,12 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { } SName name = {0}; - tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB); + if(tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 " failed to parse db name:%s", pRequest->requestId, usedbRsp.db); + } SUseDbOutput output = {0}; code = queryBuildUseDbOutput(&output, &usedbRsp); - if (code != 0) { terrno = code; if (output.dbVgroup) taosHashCleanup(output.dbVgroup->vgHash); @@ -317,26 +336,31 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, tstrerror(code1)); } else { - catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup); + if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0){ + tscError("0x%" PRIx64 " failed to update db vg info, db:%s, dbId:%" PRId64, pRequest->requestId, output.db, + output.dbId); + } output.dbVgroup = NULL; } } taosMemoryFreeClear(output.dbVgroup); - tFreeSUsedbRsp(&usedbRsp); char db[TSDB_DB_NAME_LEN] = {0}; - tNameGetDbName(&name, db); + if(tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 " failed to get db name since %s", pRequest->requestId, tstrerror(code)); + } setConnectionDB(pRequest->pTscObj, db); + taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { doRequestCallback(pRequest, pRequest->code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return 0; } @@ -353,7 +377,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { SMCreateStbRsp createRsp = {0}; SDecoder coder = {0}; tDecoderInit(&coder, pMsg->pData, pMsg->len); - tDecodeSMCreateStbRsp(&coder, &createRsp); + (void)tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0 tDecoderClear(&coder); pRequest->body.resInfo.execRes.msgType = TDMT_MND_CREATE_STB; @@ -380,7 +404,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } @@ -391,33 +415,41 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); } else { SDropDbRsp dropdbRsp = {0}; - tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp); - + if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0){ + tscError("0x%" PRIx64 " deserialize SDropDbRsp failed", pRequest->requestId); + } struct SCatalog* pCatalog = NULL; - int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (TSDB_CODE_SUCCESS == code) { - catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid); + if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0){ + tscError("0x%" PRIx64 " failed to remove db:%s", pRequest->requestId, dropdbRsp.db); + } STscObj* pTscObj = pRequest->pTscObj; SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, .requestId = pRequest->requestId, .requestObjRefId = pRequest->self, .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; - char dbFName[TSDB_DB_FNAME_LEN]; - snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB); - catalogRefreshDBVgInfo(pCatalog, &conn, dbFName); - snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB); - catalogRefreshDBVgInfo(pCatalog, &conn, dbFName); + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + (void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB); + if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName); + } + (void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB); + if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) { + tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName); + } } } +END: taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); if (pRequest->body.queryFp != NULL) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } @@ -430,7 +462,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) { SMAlterStbRsp alterRsp = {0}; SDecoder coder = {0}; tDecoderInit(&coder, pMsg->pData, pMsg->len); - tDecodeSMAlterStbRsp(&coder, &alterRsp); + (void)tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len = 0 tDecoderClear(&coder); pRequest->body.resInfo.execRes.msgType = TDMT_MND_ALTER_STB; @@ -457,57 +489,72 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) { + int32_t code = 0; + int32_t line = 0; SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + TSDB_CHECK_NULL(pBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY); pBlock->info.hasVarCol = true; pBlock->pDataBlock = taosArrayInit(SHOW_VARIABLES_RESULT_COLS, sizeof(SColumnInfoData)); - + TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY); SColumnInfoData infoData = {0}; infoData.info.type = TSDB_DATA_TYPE_VARCHAR; infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD1_LEN; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); infoData.info.type = TSDB_DATA_TYPE_VARCHAR; infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD2_LEN; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); infoData.info.type = TSDB_DATA_TYPE_VARCHAR; infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD3_LEN; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); int32_t numOfCfg = taosArrayGetSize(pVars); - blockDataEnsureCapacity(pBlock, numOfCfg); + code = blockDataEnsureCapacity(pBlock, numOfCfg); + TSDB_CHECK_CODE(code, line, END); for (int32_t i = 0, c = 0; i < numOfCfg; ++i, c = 0) { SVariablesInfo* pInfo = taosArrayGet(pVars, i); + TSDB_CHECK_NULL(pInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY); char name[TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(name, pInfo->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE); SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, c++); - colDataSetVal(pColInfo, i, name, false); + TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY); + code = colDataSetVal(pColInfo, i, name, false); + TSDB_CHECK_CODE(code, line, END); char value[TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(value, pInfo->value, TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, c++); - colDataSetVal(pColInfo, i, value, false); + TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY); + code = colDataSetVal(pColInfo, i, value, false); + TSDB_CHECK_CODE(code, line, END); char scope[TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(scope, pInfo->scope, TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE); pColInfo = taosArrayGet(pBlock->pDataBlock, c++); - colDataSetVal(pColInfo, i, scope, false); + TSDB_CHECK_NULL(pColInfo, code, line, END, TSDB_CODE_OUT_OF_MEMORY); + code = colDataSetVal(pColInfo, i, scope, false); + TSDB_CHECK_CODE(code, line, END); } pBlock->info.rows = numOfCfg; *block = pBlock; + return code; - return TSDB_CODE_SUCCESS; +END: + taosArrayDestroy(pBlock->pDataBlock); + taosMemoryFree(pBlock); + return code; } static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { @@ -577,55 +624,72 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { if (pRequest->body.queryFp != NULL) { doRequestCallback(pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) { + int32_t code = 0; + int32_t line = 0; SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + TSDB_CHECK_NULL(pBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY); pBlock->info.hasVarCol = true; pBlock->pDataBlock = taosArrayInit(COMPACT_DB_RESULT_COLS, sizeof(SColumnInfoData)); - + TSDB_CHECK_NULL(pBlock->pDataBlock, code, line, END, TSDB_CODE_OUT_OF_MEMORY); SColumnInfoData infoData = {0}; infoData.info.type = TSDB_DATA_TYPE_VARCHAR; infoData.info.bytes = COMPACT_DB_RESULT_FIELD1_LEN; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); infoData.info.type = TSDB_DATA_TYPE_INT; infoData.info.bytes = tDataTypes[TSDB_DATA_TYPE_INT].bytes; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); infoData.info.type = TSDB_DATA_TYPE_VARCHAR; infoData.info.bytes = COMPACT_DB_RESULT_FIELD3_LEN; - taosArrayPush(pBlock->pDataBlock, &infoData); + TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, TSDB_CODE_OUT_OF_MEMORY); - blockDataEnsureCapacity(pBlock, 1); + code = blockDataEnsureCapacity(pBlock, 1); + TSDB_CHECK_CODE(code, line, END); SColumnInfoData* pResultCol = taosArrayGet(pBlock->pDataBlock, 0); + TSDB_CHECK_NULL(pResultCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY); SColumnInfoData* pIdCol = taosArrayGet(pBlock->pDataBlock, 1); + TSDB_CHECK_NULL(pIdCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY); SColumnInfoData* pReasonCol = taosArrayGet(pBlock->pDataBlock, 2); + TSDB_CHECK_NULL(pReasonCol, code, line, END, TSDB_CODE_OUT_OF_MEMORY); + char result[COMPACT_DB_RESULT_FIELD1_LEN] = {0}; char reason[COMPACT_DB_RESULT_FIELD3_LEN] = {0}; if (pRsp->bAccepted) { STR_TO_VARSTR(result, "accepted"); - colDataSetVal(pResultCol, 0, result, false); - colDataSetVal(pIdCol, 0, (void*)&pRsp->compactId, false); + code = colDataSetVal(pResultCol, 0, result, false); + TSDB_CHECK_CODE(code, line, END); + code = colDataSetVal(pIdCol, 0, (void*)&pRsp->compactId, false); + TSDB_CHECK_CODE(code, line, END); STR_TO_VARSTR(reason, "success"); - colDataSetVal(pReasonCol, 0, reason, false); + code = colDataSetVal(pReasonCol, 0, reason, false); + TSDB_CHECK_CODE(code, line, END); } else { STR_TO_VARSTR(result, "rejected"); - colDataSetVal(pResultCol, 0, result, false); + code = colDataSetVal(pResultCol, 0, result, false); + TSDB_CHECK_CODE(code, line, END); colDataSetNULL(pIdCol, 0); STR_TO_VARSTR(reason, "compaction is ongoing"); - colDataSetVal(pReasonCol, 0, reason, false); + code = colDataSetVal(pReasonCol, 0, reason, false); + TSDB_CHECK_CODE(code, line, END); } pBlock->info.rows = 1; *block = pBlock; return TSDB_CODE_SUCCESS; +END: + taosMemoryFree(pBlock); + taosArrayDestroy(pBlock->pDataBlock); + return code; } static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetrieveTableRsp** pRsp) { @@ -696,7 +760,7 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) { if (pRequest->body.queryFp != NULL) { pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 17b52521b8..9f7aeabbe4 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -14,15 +14,20 @@ static FORCE_INLINE int32_t stmtAllocQNodeFromBuf(STableBufInfo* pTblBuf, void** pTblBuf->buffOffset += pTblBuf->buffUnit; } else if (pTblBuf->buffIdx < taosArrayGetSize(pTblBuf->pBufList)) { pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, pTblBuf->buffIdx++); + if (NULL == pTblBuf->pCurBuff) { + return TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY); + } *pBuf = pTblBuf->pCurBuff; pTblBuf->buffOffset = pTblBuf->buffUnit; } else { void* buff = taosMemoryMalloc(pTblBuf->buffSize); if (NULL == buff) { - return TSDB_CODE_OUT_OF_MEMORY; + return terrno; } - taosArrayPush(pTblBuf->pBufList, &buff); + if(taosArrayPush(pTblBuf->pBufList, &buff) == NULL){ + return terrno; + } pTblBuf->buffIdx++; pTblBuf->pCurBuff = buff; @@ -48,7 +53,7 @@ bool stmtDequeue(STscStmt* pStmt, SStmtQNode** param) { *param = node; - atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1); + (void)atomic_sub_fetch_64(&pStmt->queue.qRemainNum, 1); return true; } @@ -58,7 +63,7 @@ void stmtEnqueue(STscStmt* pStmt, SStmtQNode* param) { pStmt->queue.tail = param; pStmt->stat.bindDataNum++; - atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1); + (void)atomic_add_fetch_64(&pStmt->queue.qRemainNum, 1); } static int32_t stmtCreateRequest(STscStmt* pStmt) { @@ -183,8 +188,8 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) { if (NULL == pRes->fields || NULL == pRes->userFields) { STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size); - memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size); + (void)memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size); + (void)memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size); return TSDB_CODE_SUCCESS; } @@ -201,7 +206,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) { if (NULL == pStmt->exec.pRequest->body.resInfo.fields) { STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size); + (void)memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size); } if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) { @@ -209,7 +214,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) { if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) { STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size); + (void)memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size); } return TSDB_CODE_SUCCESS; @@ -219,10 +224,13 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, bool autoCreateTbl) { STscStmt* pStmt = (STscStmt*)stmt; char tbFName[TSDB_TABLE_FNAME_LEN]; - tNameExtractFullName(tbName, tbFName); + int32_t code = tNameExtractFullName(tbName, tbFName); + if (code != 0){ + return code; + } - memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName)); - strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1); + (void)memcpy(&pStmt->bInfo.sname, tbName, sizeof(*tbName)); + (void)strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1); pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0; pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid; @@ -383,17 +391,21 @@ int32_t stmtCleanBindInfo(STscStmt* pStmt) { taosMemoryFreeClear(pStmt->bInfo.boundTags); } pStmt->bInfo.stbFName[0] = 0; - ; + return TSDB_CODE_SUCCESS; } void stmtFreeTableBlkList(STableColsData* pTb) { - qResetStmtColumns(pTb->aCol, true); + (void)qResetStmtColumns(pTb->aCol, true); taosArrayDestroy(pTb->aCol); } void stmtResetQueueTableBuf(STableBufInfo* pTblBuf, SStmtQueue* pQueue) { pTblBuf->pCurBuff = taosArrayGetP(pTblBuf->pBufList, 0); + if (NULL == pTblBuf->pCurBuff) { + tscError("QInfo:%p, failed to get buffer from list", pTblBuf); + return; + } pTblBuf->buffIdx = 1; pTblBuf->buffOffset = sizeof(*pQueue->head); @@ -438,7 +450,7 @@ int32_t stmtCleanExecInfo(STscStmt* pStmt, bool keepTable, bool deepClean) { } qDestroyStmtDataBlock(pBlocks); - taosHashRemove(pStmt->exec.pBlockHash, key, keyLen); + STMT_ERR_RET(taosHashRemove(pStmt->exec.pBlockHash, key, keyLen)); pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter); } @@ -505,7 +517,7 @@ int32_t stmtCleanSQLInfo(STscStmt* pStmt) { qDestroyStmtDataBlock(pStmt->sql.siInfo.pDataCtx); taosArrayDestroyEx(pStmt->sql.siInfo.pTableCols, stmtFreeTbCols); - memset(&pStmt->sql, 0, sizeof(pStmt->sql)); + (void)memset(&pStmt->sql, 0, sizeof(pStmt->sql)); pStmt->sql.siInfo.tableColsReady = true; STMT_DLOG_E("end to free SQL info"); @@ -628,7 +640,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) { tscDebug("tb %s not exist", pStmt->bInfo.tbFName); - stmtCleanBindInfo(pStmt); + STMT_ERR_RET(stmtCleanBindInfo(pStmt)); STMT_ERR_RET(code); } @@ -726,6 +738,9 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) { for (int32_t i = 0; i < pStmt->sql.siInfo.pTableColsIdx; ++i) { SArray** p = (SArray**)TARRAY_GET_ELEM(pStmt->sql.siInfo.pTableCols, i); *p = taosArrayInit(20, POINTER_BYTES); + if (*p == NULL) { + STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } } atomic_store_8((int8_t*)&pStmt->sql.siInfo.tableColsReady, true); @@ -735,7 +750,7 @@ int32_t stmtAsyncOutput(STscStmt* pStmt, void* param) { // taosMemoryFree(pParam->pTbData); - atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1); + (void)atomic_sub_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1); } return TSDB_CODE_SUCCESS; } @@ -757,7 +772,7 @@ void* stmtBindThreadFunc(void* param) { continue; } - stmtAsyncOutput(pStmt, asyncParam); + (void)stmtAsyncOutput(pStmt, asyncParam); } qInfo("stmt bind thread stopped"); @@ -767,8 +782,12 @@ void* stmtBindThreadFunc(void* param) { int32_t stmtStartBindThread(STscStmt* pStmt) { TdThreadAttr thAttr; - taosThreadAttrInit(&thAttr); - taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); + if (taosThreadAttrInit(&thAttr) != 0) { + return TSDB_CODE_TSC_INTERNAL_ERROR; + } + if (taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE) != 0) { + return TSDB_CODE_TSC_INTERNAL_ERROR; + } if (taosThreadCreate(&pStmt->bindThread, &thAttr, stmtBindThreadFunc, pStmt) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -777,7 +796,7 @@ int32_t stmtStartBindThread(STscStmt* pStmt) { pStmt->bindThreadInUse = true; - taosThreadAttrDestroy(&thAttr); + (void)taosThreadAttrDestroy(&thAttr); return TSDB_CODE_SUCCESS; } @@ -800,7 +819,9 @@ int32_t stmtInitTableBuf(STableBufInfo* pTblBuf) { return TSDB_CODE_OUT_OF_MEMORY; } - taosArrayPush(pTblBuf->pBufList, &buff); + if (taosArrayPush(pTblBuf->pBufList, &buff) == NULL){ + return TSDB_CODE_OUT_OF_MEMORY; + } pTblBuf->pCurBuff = buff; pTblBuf->buffIdx = 1; @@ -834,7 +855,7 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) { pStmt->errCode = TSDB_CODE_SUCCESS; if (NULL != pOptions) { - memcpy(&pStmt->options, pOptions, sizeof(pStmt->options)); + (void)memcpy(&pStmt->options, pOptions, sizeof(pStmt->options)); if (pOptions->singleStbInsert && pOptions->singleTableBindOnce) { pStmt->stbInterlaceMode = true; } @@ -848,24 +869,26 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid, TAOS_STMT_OPTIONS* pOptions) { pStmt->sql.siInfo.pTableHash = tSimpleHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY)); if (NULL == pStmt->sql.siInfo.pTableHash) { terrno = TSDB_CODE_OUT_OF_MEMORY; - stmtClose(pStmt); + (void)stmtClose(pStmt); return NULL; } pStmt->sql.siInfo.pTableCols = taosArrayInit(STMT_TABLE_COLS_NUM, POINTER_BYTES); if (NULL == pStmt->sql.siInfo.pTableCols) { terrno = TSDB_CODE_OUT_OF_MEMORY; - stmtClose(pStmt); + (void)stmtClose(pStmt); return NULL; } code = stmtInitTableBuf(&pStmt->sql.siInfo.tbBuf); if (TSDB_CODE_SUCCESS == code) { - stmtInitQueue(pStmt); + code = stmtInitQueue(pStmt); + } + if (TSDB_CODE_SUCCESS == code) { code = stmtStartBindThread(pStmt); } if (TSDB_CODE_SUCCESS != code) { terrno = code; - stmtClose(pStmt); + (void)stmtClose(pStmt); return NULL; } } @@ -904,7 +927,7 @@ int stmtPrepare(TAOS_STMT* stmt, const char* sql, unsigned long length) { char* dbName = NULL; if (qParseDbName(sql, length, &dbName)) { - stmtSetDbName(stmt, dbName); + STMT_ERR_RET(stmtSetDbName(stmt, dbName)); taosMemoryFreeClear(dbName); } @@ -928,7 +951,9 @@ int32_t stmtInitStbInterlaceTableInfo(STscStmt* pStmt) { return TSDB_CODE_OUT_OF_MEMORY; } - taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols); + if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } pStmt->sql.siInfo.boundTags = pStmt->bInfo.boundTags; @@ -966,7 +991,7 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) { STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTBNAME)); int32_t insert = 0; - stmtIsInsert(stmt, &insert); + STMT_ERR_RET(stmtIsInsert(stmt, &insert)); if (0 == insert) { tscError("set tb name not available for none insert statement"); STMT_ERR_RET(TSDB_CODE_TSC_STMT_API_ERROR); @@ -977,18 +1002,18 @@ int stmtSetTbName(TAOS_STMT* stmt, const char* tbName) { STMT_ERR_RET(qCreateSName(&pStmt->bInfo.sname, tbName, pStmt->taos->acctId, pStmt->exec.pRequest->pDb, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen)); - tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName); + STMT_ERR_RET(tNameExtractFullName(&pStmt->bInfo.sname, pStmt->bInfo.tbFName)); STMT_ERR_RET(stmtGetFromCache(pStmt)); if (pStmt->bInfo.needParse) { - strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1); + (void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1); pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0; STMT_ERR_RET(stmtParseSql(pStmt)); } } else { - strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1); + (void)strncpy(pStmt->bInfo.tbName, tbName, sizeof(pStmt->bInfo.tbName) - 1); pStmt->bInfo.tbName[sizeof(pStmt->bInfo.tbName) - 1] = 0; pStmt->exec.pRequest->requestId++; pStmt->bInfo.needParse = false; @@ -1136,13 +1161,13 @@ int32_t stmtAppendTablePostHandle(STscStmt* pStmt, SStmtQNode* param) { } if (0 == pStmt->sql.siInfo.firstName[0]) { - strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName); + (void)strcpy(pStmt->sql.siInfo.firstName, pStmt->bInfo.tbName); } param->tblData.getFromHash = pStmt->sql.siInfo.tbFromHash; param->next = NULL; - atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1); + (void)atomic_add_fetch_64(&pStmt->sql.siInfo.tbRemainNum, 1); stmtEnqueue(pStmt, param); @@ -1162,7 +1187,9 @@ static FORCE_INLINE int32_t stmtGetTableColsFromCache(STscStmt* pStmt, SArray** return TSDB_CODE_OUT_OF_MEMORY; } - taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols); + if (taosArrayPush(pStmt->sql.siInfo.pTableCols, &pTblCols) == NULL){ + return TSDB_CODE_OUT_OF_MEMORY; + } } } } @@ -1221,8 +1248,8 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { STMT_ERR_RET(qStmtParseQuerySql(&ctx, pStmt->sql.pQuery)); if (pStmt->sql.pQuery->haveResultSet) { - setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema, - pStmt->sql.pQuery->numOfResCols); + STMT_ERR_RET(setResSchemaInfo(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->pResSchema, + pStmt->sql.pQuery->numOfResCols)); taosMemoryFreeClear(pStmt->sql.pQuery->pResSchema); setResPrecision(&pStmt->exec.pRequest->body.resInfo, pStmt->sql.pQuery->precision); } @@ -1274,7 +1301,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { // param->tblData.aCol = taosArrayInit(20, POINTER_BYTES); param->restoreTbCols = false; - strcpy(param->tblData.tbName, pStmt->bInfo.tbName); + (void)strcpy(param->tblData.tbName, pStmt->bInfo.tbName); } int64_t startUs3 = taosGetTimestampUs(); @@ -1428,7 +1455,7 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) { .requestId = pStmt->exec.pRequest->requestId, .requestObjRefId = pStmt->exec.pRequest->self, .mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)}; - int32_t code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta); + code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta); pStmt->stat.ctgGetTbMetaNum++; @@ -1515,7 +1542,7 @@ int stmtExec(TAOS_STMT* stmt) { STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_EXECUTE)); if (STMT_TYPE_QUERY == pStmt->sql.type) { - launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL); + (void)launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL); } else { if (pStmt->sql.stbInterlaceMode) { int64_t startTs = taosGetTimestampUs(); @@ -1537,7 +1564,7 @@ int stmtExec(TAOS_STMT* stmt) { STMT_ERR_RET(qBuildStmtOutput(pStmt->sql.pQuery, pStmt->sql.pVgHash, pStmt->exec.pBlockHash)); } - launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL); + (void)launchQueryImpl(pStmt->exec.pRequest, pStmt->sql.pQuery, true, NULL); } if (pStmt->exec.pRequest->code && NEED_CLIENT_HANDLE_ERROR(pStmt->exec.pRequest->code)) { @@ -1562,7 +1589,7 @@ _return: taosUsleep(1); } - stmtCleanExecInfo(pStmt, (code ? false : true), false); + STMT_ERR_RET(stmtCleanExecInfo(pStmt, (code ? false : true), false)); tFreeSSubmitRsp(pRsp); @@ -1582,7 +1609,7 @@ int stmtClose(TAOS_STMT* stmt) { pStmt->queue.stopQueue = true; if (pStmt->bindThreadInUse) { - taosThreadJoin(pStmt->bindThread, NULL); + (void)taosThreadJoin(pStmt->bindThread, NULL); pStmt->bindThreadInUse = false; } @@ -1597,7 +1624,7 @@ int stmtClose(TAOS_STMT* stmt) { pStmt->stat.bindDataUs1, pStmt->stat.bindDataUs2, pStmt->stat.bindDataUs3, pStmt->stat.bindDataUs4, pStmt->stat.addBatchUs, pStmt->stat.execWaitUs, pStmt->stat.execUseUs); - stmtCleanSQLInfo(pStmt); + STMT_ERR_RET(stmtCleanSQLInfo(pStmt)); taosMemoryFree(stmt); return TSDB_CODE_SUCCESS; diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index ff1b0ce185..46c3cf6622 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -2934,7 +2934,7 @@ int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pRes doFreeReqResultInfo(&pRspObj->resInfo); SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(common->blockSchema, pRspObj->resIter); if (pSW){ - setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols); + TAOS_CHECK_RETURN(setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols)); } } diff --git a/source/client/src/clientTmqConnector.c b/source/client/src/clientTmqConnector.c index 2bea738c23..26eed6fedf 100644 --- a/source/client/src/clientTmqConnector.c +++ b/source/client/src/clientTmqConnector.c @@ -41,7 +41,7 @@ void tmqGlobalMethod(JNIEnv *env) { } if (g_vm == NULL) { - (*env)->GetJavaVM(env, &g_vm); + (void)((*env)->GetJavaVM(env, &g_vm)); } jclass offset = (*env)->FindClass(env, "com/taosdata/jdbc/tmq/OffsetWaitCallback"); @@ -68,7 +68,7 @@ void tmqAssignmentMethod(JNIEnv *env) { } if (g_vm == NULL) { - (*env)->GetJavaVM(env, &g_vm); + (void)((*env)->GetJavaVM(env, &g_vm)); } jclass assignment = (*env)->FindClass(env, "com/taosdata/jdbc/tmq/Assignment"); @@ -104,7 +104,7 @@ void commit_cb(tmq_t *tmq, int32_t code, void *param) { param = NULL; if (needDetach) { - (*g_vm)->DetachCurrentThread(g_vm); + (void)((*g_vm)->DetachCurrentThread(g_vm)); } env = NULL; } @@ -126,7 +126,7 @@ void consumer_callback(tmq_t *tmq, int32_t code, void *param) { param = NULL; if (needDetach) { - (*g_vm)->DetachCurrentThread(g_vm); + (void)((*g_vm)->DetachCurrentThread(g_vm)); } env = NULL; } @@ -493,7 +493,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp( (*env)->SetIntField(env, metadataObj, g_metadataColindexField, i); jstring metadataObjColname = (*env)->NewStringUTF(env, fields[i].name); (*env)->SetObjectField(env, metadataObj, g_metadataColnameField, metadataObjColname); - (*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj); + (void)(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj); } (*env)->CallVoidMethod(env, rowobj, g_blockdataSetNumOfRowsFp, (jint)numOfRows); @@ -567,7 +567,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqGetTopicAssign (*env)->CallVoidMethod(env, jassignment, g_assignmentSetCurrentOffset, assignment.currentOffset); (*env)->CallVoidMethod(env, jassignment, g_assignmentSetBegin, assignment.begin); (*env)->CallVoidMethod(env, jassignment, g_assignmentSetEnd, assignment.end); - (*env)->CallBooleanMethod(env, jarrayList, g_arrayListAddFp, jassignment); + (void)(*env)->CallBooleanMethod(env, jarrayList, g_arrayListAddFp, jassignment); } tmq_free_assignment(pAssign); return JNI_SUCCESS; diff --git a/source/client/test/clientMonitorTests.cpp b/source/client/test/clientMonitorTests.cpp index e0518a2ce2..65adb7cdae 100644 --- a/source/client/test/clientMonitorTests.cpp +++ b/source/client/test/clientMonitorTests.cpp @@ -86,7 +86,7 @@ static char* readFile(TdFilePtr pFile, int64_t *offset, int64_t size){ return NULL; } char* buf = pCont; - strcat(buf++, "["); + (void)strcat(buf++, "["); int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX); if (readSize <= 0) { if (readSize < 0){ @@ -153,7 +153,7 @@ TEST(clientMonitorTest, ReadOneFile) { const int size = 10; for(int i = 0; i < batch; i++){ char value[size] = {0}; - memset(value, '0' + i, size - 1); + (void)memset(value, '0' + i, size - 1); if (taosWriteFile(pFile, value, strlen(value) + 1) < 0){ uError("failed to write len to file:%p since %s", pFile, terrstr()); } diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 836a171ad7..e318ff1972 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -32,7 +32,7 @@ namespace { void printSubResults(void* pRes, int32_t* totalRows) { - char buf[1024]; + char buf[1024] = {0}; int32_t vgId = tmq_get_vgroup_id(pRes); int64_t offset = tmq_get_vgroup_offset(pRes); @@ -43,9 +43,10 @@ void printSubResults(void* pRes, int32_t* totalRows) { } TAOS_FIELD* fields = taos_fetch_fields(pRes); + assert(fields != NULL); int32_t numOfFields = taos_field_count(pRes); int32_t precision = taos_result_precision(pRes); - taos_print_row(buf, row, fields, numOfFields); + (void)taos_print_row(buf, row, fields, numOfFields); *totalRows += 1; std::cout << "vgId:" << vgId << ", offset:" << offset << ", precision:" << precision << ", row content:" << buf << std::endl; @@ -59,12 +60,13 @@ void showDB(TAOS* pConn) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } } @@ -78,19 +80,19 @@ void printResult(TAOS_RES* pRes) { while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t* length = taos_fetch_lengths(pRes); // for(int32_t i = 0; i < numOfFields; ++i) { - // printf("(%d):%d " , i, length[i]); + // (void)printf("(%d):%d " , i, length[i]); // } - // printf("\n"); + // (void)printf("\n"); // // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - // printf("%s\n", str); + // (void)printf("%s\n", str); // memset(str, 0, sizeof(str)); } } void fetchCallback(void* param, void* res, int32_t numOfRow) { #if 0 - printf("numOfRow = %d \n", numOfRow); + (void)printf("numOfRow = %d \n", numOfRow); int numFields = taos_num_fields(res); TAOS_FIELD *fields = taos_fetch_fields(res); TAOS *_taos = (TAOS *)param; @@ -100,18 +102,18 @@ void fetchCallback(void* param, void* res, int32_t numOfRow) { char temp[256] = {0}; taos_print_row(temp, row, fields, numFields); - printf("%s\n", temp); + (void)printf("%s\n", temp); } taos_fetch_rows_a(res, fetchCallback, _taos); } else { - printf("no more data, close the connection.\n"); + (void)printf("no more data, close the connection.\n"); // taos_free_result(res); // taos_close(_taos); // taos_cleanup(); } #endif if (numOfRow == 0) { - printf("completed\n"); + (void)printf("completed\n"); return; } @@ -120,26 +122,26 @@ void fetchCallback(void* param, void* res, int32_t numOfRow) { void queryCallback(void* param, void* res, int32_t code) { if (code != TSDB_CODE_SUCCESS) { - printf("failed to execute, reason:%s\n", taos_errstr(res)); + (void)printf("failed to execute, reason:%s\n", taos_errstr(res)); } - printf("start to fetch data\n"); + (void)printf("start to fetch data\n"); taos_fetch_raw_block_a(res, fetchCallback, param); } void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t startTs, const char* pVarchar) { char str[1024] = {0}; - sprintf(str, "create table if not exists tu%d using st2 tags(%d)", index, index); + (void)sprintf(str, "create table if not exists tu%d using st2 tags(%d)", index, index); TAOS_RES* pRes = taos_query(pConn, str); if (taos_errno(pRes) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); if (startTs == 0) { for (int32_t i = 0; i < numOfRows; i += 20) { char sql[1024] = {0}; - sprintf(sql, + (void)sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -149,7 +151,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start i + 14, i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19); TAOS_RES* p = taos_query(pConn, sql); if (taos_errno(p) != 0) { - printf("failed to insert data, reason:%s\n", taos_errstr(p)); + (void)printf("failed to insert data, reason:%s\n", taos_errstr(p)); } taos_free_result(p); @@ -157,7 +159,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start } else { for (int32_t i = 0; i < numOfRows; i += 20) { char sql[1024*50] = {0}; - sprintf(sql, + (void)sprintf(sql, "insert into tu%d values(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, " "%d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, " "'%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')", @@ -167,8 +169,9 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start i + 14, pVarchar, startTs + 15, i + 15, pVarchar, startTs + 16, i + 16, pVarchar, startTs + 17, i + 17, pVarchar, startTs + 18, i + 18, pVarchar, startTs + 19, i + 19, pVarchar); TAOS_RES* p = taos_query(pConn, sql); + assert(p != NULL); if (taos_errno(p) != 0) { - printf("failed to insert data, reason:%s\n", taos_errstr(p)); + (void)printf("failed to insert data, reason:%s\n", taos_errstr(p)); } // startTs += 20; @@ -180,7 +183,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start void* queryThread(void* arg) { TAOS* pConn = taos_connect("192.168.0.209", "root", "taosdata", NULL, 0); if (pConn == NULL) { - printf("failed to connect to db, reason:%s", taos_errstr(pConn)); + (void)printf("failed to connect to db, reason:%s", taos_errstr(pConn)); return NULL; } @@ -192,7 +195,7 @@ void* queryThread(void* arg) { "SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= " "1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"); if (taos_errno(pRes) != 0) { - printf("failed, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed, reason:%s\n", taos_errstr(pRes)); } else { printResult(pRes); } @@ -200,7 +203,7 @@ void* queryThread(void* arg) { taos_free_result(pRes); el += (taosGetTimestampUs() - st); if (i % 1000 == 0 && i != 0) { - printf("total:%d, avg time:%.2fms\n", i, el / (double)(i * 1000)); + (void)printf("total:%d, avg time:%.2fms\n", i, el / (double)(i * 1000)); } } @@ -211,32 +214,35 @@ void* queryThread(void* arg) { int32_t numOfThreads = 1; void tmq_commit_cb_print(tmq_t* pTmq, int32_t code, void* param) { -// printf("auto commit success, code:%d\n", code); +// (void)printf("auto commit success, code:%d\n", code); } void* doConsumeData(void* param) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - + assert(pConn != NULL); tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpName41"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "true"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + assert(conf != NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + (void)tmq_conf_set(conf, "group.id", "cgrpName41"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "true"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "topic_t2"); + assert(topicList != NULL); + (void)tmq_list_append(topicList, "topic_t2"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); @@ -252,15 +258,15 @@ void* doConsumeData(void* param) { while (1) { TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { - char buf[1024]; + char buf[1024] = {0}; const char* topicName = tmq_get_topic_name(pRes); const char* dbName = tmq_get_db_name(pRes); int32_t vgroupId = tmq_get_vgroup_id(pRes); - printf("topic: %s\n", topicName); - printf("db: %s\n", dbName); - printf("vgroup id: %d\n", vgroupId); + (void)printf("topic: %s\n", topicName); + (void)printf("db: %s\n", dbName); + (void)printf("vgroup id: %d\n", vgroupId); while (1) { TAOS_ROW row = taos_fetch_row(pRes); @@ -269,11 +275,12 @@ void* doConsumeData(void* param) { } fields = taos_fetch_fields(pRes); + assert(fields != NULL); numOfFields = taos_field_count(pRes); precision = taos_result_precision(pRes); - taos_print_row(buf, row, fields, numOfFields); + (void)taos_print_row(buf, row, fields, numOfFields); totalRows += 1; - // printf("precision: %d, row content: %s\n", precision, buf); + // (void)printf("precision: %d, row content: %s\n", precision, buf); } taos_free_result(pRes); @@ -282,9 +289,9 @@ void* doConsumeData(void* param) { } } - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return NULL; } @@ -297,7 +304,7 @@ int main(int argc, char** argv) { } numOfThreads = TMAX(numOfThreads, 1); - printf("the runing threads is:%d", numOfThreads); + (void)printf("the runing threads is:%d", numOfThreads); return RUN_ALL_TESTS(); } @@ -311,7 +318,7 @@ TEST(clientCase, connect_Test) { taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { - printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); + (void)printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); } taos_close(pConn); } @@ -322,7 +329,7 @@ TEST(clientCase, create_user_Test) { TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -335,7 +342,7 @@ TEST(clientCase, create_account_Test) { TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -348,7 +355,7 @@ TEST(clientCase, drop_account_Test) { TAOS_RES* pRes = taos_query(pConn, "drop account aabc"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -363,12 +370,13 @@ TEST(clientCase, show_user_Test) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -381,7 +389,7 @@ TEST(clientCase, drop_user_Test) { TAOS_RES* pRes = taos_query(pConn, "drop user abc"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -396,12 +404,13 @@ TEST(clientCase, show_db_Test) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_close(pConn); @@ -413,7 +422,7 @@ TEST(clientCase, create_db_Test) { TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -426,7 +435,7 @@ TEST(clientCase, create_db_Test) { pRes = taos_query(pConn, "create database abc1 vgroups 4"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } taos_close(pConn); } @@ -437,13 +446,13 @@ TEST(clientCase, create_dnode_Test) { TAOS_RES* pRes = taos_query(pConn, "create dnode abc1 port 7000"); if (taos_errno(pRes) != 0) { - printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000"); if (taos_errno(pRes) != 0) { - printf("failed to create dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -456,7 +465,7 @@ TEST(clientCase, drop_dnode_Test) { TAOS_RES* pRes = taos_query(pConn, "drop dnode 3"); if (taos_errno(pRes) != 0) { - printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -467,7 +476,7 @@ TEST(clientCase, drop_dnode_Test) { pRes = taos_query(pConn, "drop dnode 4"); if (taos_errno(pRes) != 0) { - printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -480,7 +489,7 @@ TEST(clientCase, use_db_test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in use db, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -500,7 +509,7 @@ TEST(clientCase, use_db_test) { // // TAOS_RES* pRes = taos_query(pConn, "drop database abc1"); // if (taos_errno(pRes) != 0) { -// printf("failed to drop db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to drop db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // @@ -508,7 +517,7 @@ TEST(clientCase, use_db_test) { // // pRes = taos_query(pConn, "create database abc1"); // if (taos_errno(pRes) != 0) { -// printf("create to drop db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("create to drop db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // taos_close(pConn); @@ -520,7 +529,7 @@ TEST(clientCase, create_stable_Test) { TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -528,7 +537,7 @@ TEST(clientCase, create_stable_Test) { pRes = taos_query(pConn, "create table if not exists abc1.st1(ts timestamp, k int) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("error in create stable, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create stable, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -540,14 +549,14 @@ TEST(clientCase, create_stable_Test) { // pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)"); // if (taos_errno(pRes) != 0) { - // printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // (void)printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); // } // // pRes = taos_query(pConn, "use abc1"); // taos_free_result(pRes); // pRes = taos_query(pConn, "drop stable `123_$^)`"); // if (taos_errno(pRes) != 0) { - // printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // (void)printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); // } taos_close(pConn); @@ -578,19 +587,19 @@ TEST(clientCase, create_ctable_Test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, k int ) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("failed to create stable, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create stable, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create table tu using st1 tags('2021-10-10 1:1:1');"); if (taos_errno(pRes) != 0) { - printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -603,7 +612,7 @@ TEST(clientCase, show_stable_Test) { TAOS_RES* pRes = taos_query(pConn, "show abc1.stables"); if (taos_errno(pRes) != 0) { - printf("failed to show stables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show stables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -615,7 +624,7 @@ TEST(clientCase, show_stable_Test) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -628,13 +637,13 @@ TEST(clientCase, show_vgroup_Test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "show vgroups"); if (taos_errno(pRes) != 0) { - printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -647,7 +656,7 @@ TEST(clientCase, show_vgroup_Test) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -660,7 +669,7 @@ TEST(clientCase, create_multiple_tables) { TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); if (taos_errno(pRes) != 0) { - printf("failed to create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); taos_close(pConn); return; @@ -669,7 +678,7 @@ TEST(clientCase, create_multiple_tables) { pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); taos_close(pConn); return; @@ -679,14 +688,14 @@ TEST(clientCase, create_multiple_tables) { pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, k int) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("failed to create stable tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create stable tables, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists t_2 using st1 tags(1)"); if (taos_errno(pRes) != 0) { - printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -694,7 +703,7 @@ TEST(clientCase, create_multiple_tables) { taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists t_3 using st1 tags(2)"); if (taos_errno(pRes) != 0) { - printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -706,17 +715,17 @@ TEST(clientCase, create_multiple_tables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); for (int32_t i = 0; i < 500; i += 2) { char sql[512] = {0}; - snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); + (void)snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); TAOS_RES* pres = taos_query(pConn, sql); if (taos_errno(pres) != 0) { - printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); + (void)printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); } taos_free_result(pres); } @@ -730,15 +739,15 @@ TEST(clientCase, show_table_Test) { TAOS_RES* pRes = taos_query(pConn, "show tables"); if (taos_errno(pRes) != 0) { - printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); - taos_query(pConn, "use abc1"); + (void)taos_query(pConn, "use abc1"); pRes = taos_query(pConn, "show tables"); if (taos_errno(pRes) != 0) { - printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); } @@ -751,7 +760,7 @@ TEST(clientCase, show_table_Test) { while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%d: %s\n", ++count, str); + (void)printf("%d: %s\n", ++count, str); } taos_free_result(pRes); @@ -764,19 +773,19 @@ TEST(clientCase, show_table_Test) { // // TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); // if (taos_errno(pRes) != 0) { -// printf("error in creating db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("error in creating db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // // pRes = taos_query(pConn, "use abc1"); // if (taos_errno(pRes) != 0) { -// printf("error in using db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("error in using db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // // pRes = taos_query(pConn, "drop stable st1"); // if (taos_errno(pRes) != 0) { -// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); // } // // taos_free_result(pRes); @@ -790,10 +799,10 @@ TEST(clientCase, generated_request_id_test) { uint64_t v = generateRequestId(); void* result = taosHashGet(phash, &v, sizeof(v)); if (result != nullptr) { - // printf("0x%llx, index:%d\n", v, i); + // (void)printf("0x%llx, index:%d\n", v, i); } assert(result == nullptr); - taosHashPut(phash, &v, sizeof(v), NULL, 0); + (void)taosHashPut(phash, &v, sizeof(v), NULL, 0); } taosHashCleanup(phash); @@ -808,7 +817,7 @@ TEST(clientCase, insert_test) { pRes = taos_query(pConn, "insert into t_2 values(now, 1)"); if (taos_errno(pRes) != 0) { - printf("failed to create into table t_2, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create into table t_2, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -825,7 +834,7 @@ TEST(clientCase, projection_query_tables) { // TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); // if (taos_errno(pRes) != 0) { - // printf("error in create db, reason:%s\n", taos_errstr(pRes)); + // (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); pRes= taos_query(pConn, "use abc1"); @@ -833,7 +842,7 @@ TEST(clientCase, projection_query_tables) { pRes = taos_query(pConn, "create table tu using st2 tags(2)"); if (taos_errno(pRes) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -848,11 +857,11 @@ TEST(clientCase, projection_query_tables) { for(int32_t i = 0; i < 1; ++i) { char str[1024] = {0}; - sprintf(str, "create table if not exists tu%d using st2 tags(%d)", i, i); + (void)sprintf(str, "create table if not exists tu%d using st2 tags(%d)", i, i); TAOS_RES* px = taos_query(pConn, str); if (taos_errno(px) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(px); } @@ -866,7 +875,7 @@ TEST(clientCase, projection_query_tables) { pRes = taos_query(pConn, "select * from abc1.st2"); if (taos_errno(pRes) != 0) { - printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -878,7 +887,7 @@ TEST(clientCase, projection_query_tables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); +// (void)printf("%s\n", str); } taos_free_result(pRes); @@ -889,7 +898,7 @@ TEST(clientCase, tsbs_perf_test) { TdThread qid[20] = {0}; for (int32_t i = 0; i < numOfThreads; ++i) { - taosThreadCreate(&qid[i], NULL, queryThread, NULL); + (void)taosThreadCreate(&qid[i], NULL, queryThread, NULL); } getchar(); } @@ -903,7 +912,7 @@ TEST(clientCase, projection_query_stables) { // pRes = taos_query(pConn, "select * from st2"); // if (taos_errno(pRes) != 0) { -// printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); // taos_free_result(pRes); // ASSERT_TRUE(false); // } @@ -925,15 +934,15 @@ TEST(clientCase, projection_query_stables) { i += numOfRows; if ( (i / 1000000) > prev) { - printf("%d\n", i); + (void)printf("%d\n", i); prev = i/1000000; } - //printf("%d\n", i); + //(void)printf("%d\n", i); } // while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); // if (i++ % 100000 == 0) { -// printf("%d\n", i); +// (void)printf("%d\n", i); // } // } @@ -947,7 +956,7 @@ TEST(clientCase, agg_query_tables) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -958,7 +967,7 @@ TEST(clientCase, agg_query_tables) { char s[256] = {0}; while (1) { - sprintf(s, "insert into t1 values(%ld, %d)", st + i, i); + (void)sprintf(s, "insert into t1 values(%ld, %d)", st + i, i); pRes = taos_query(pConn, s); int32_t ret = taos_errno(pRes); @@ -982,7 +991,7 @@ TEST(clientCase, agg_query_tables) { // pRes = taos_query(pConn, "show table distributed tup"); // if (taos_errno(pRes) != 0) { -// printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); // taos_free_result(pRes); // ASSERT_TRUE(false); // } @@ -1008,11 +1017,11 @@ TEST(clientCase, async_api_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - taos_query(pConn, "use abc1"); + (void)taos_query(pConn, "use abc1"); TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')"); if (taos_errno(pRes) != 0) { - printf("failed, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed, reason:%s\n", taos_errstr(pRes)); } int32_t n = 0; @@ -1024,17 +1033,17 @@ TEST(clientCase, async_api_test) { while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t* length = taos_fetch_lengths(pRes); for (int32_t i = 0; i < numOfFields; ++i) { - printf("(%d):%d ", i, length[i]); + (void)printf("(%d):%d ", i, length[i]); } - printf("\n"); + (void)printf("\n"); int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); - memset(str, 0, sizeof(str)); + (void)printf("%s\n", str); + (void)memset(str, 0, sizeof(str)); } taos_query_a(pConn, "select count(*) from tu", queryCallback, pConn); - getchar(); + (void)getchar(); taos_close(pConn); } @@ -1044,7 +1053,7 @@ TEST(clientCase, update_test) { TAOS_RES* pRes = taos_query(pConn, "select cast(0 as timestamp)-1y"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create database, code:%s", taos_errstr(pRes)); + (void)printf("failed to create database, code:%s", taos_errstr(pRes)); taos_free_result(pRes); return; } @@ -1053,7 +1062,7 @@ TEST(clientCase, update_test) { pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to use db, code:%s", taos_errstr(pRes)); + (void)printf("failed to use db, code:%s", taos_errstr(pRes)); taos_free_result(pRes); return; } @@ -1061,14 +1070,14 @@ TEST(clientCase, update_test) { pRes = taos_query(pConn, "create table tup (ts timestamp, k int);"); if (taos_errno(pRes) != 0) { - printf("failed to create table, reason:%s", taos_errstr(pRes)); + (void)printf("failed to create table, reason:%s", taos_errstr(pRes)); } taos_free_result(pRes); char s[256] = {0}; for (int32_t i = 0; i < 17000; ++i) { - sprintf(s, "insert into tup values(now+%da, %d)", i, i); + (void)sprintf(s, "insert into tup values(now+%da, %d)", i, i); pRes = taos_query(pConn, s); taos_free_result(pRes); } @@ -1080,32 +1089,32 @@ TEST(clientCase, sub_db_test) { // TAOS_RES* pRes = taos_query(pConn, "create topic topic_t1 as select * from t1"); // if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - // printf("failed to create topic, code:%s", taos_errstr(pRes)); + // (void)printf("failed to create topic, code:%s", taos_errstr(pRes)); // taos_free_result(pRes); // return; // } tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpNamedb"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "false"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + (void)tmq_conf_set(conf, "group.id", "cgrpNamedb"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "false"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "topic_t1"); + (void)tmq_list_append(topicList, "topic_t1"); // tmq_list_append(topicList, "topic_s2"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1127,12 +1136,12 @@ TEST(clientCase, sub_db_test) { const char* dbName = tmq_get_db_name(pRes); int32_t vgroupId = tmq_get_vgroup_id(pRes); - printf("topic: %s\n", topicName); - printf("db: %s\n", dbName); - printf("vgroup id: %d\n", vgroupId); + (void)printf("topic: %s\n", topicName); + (void)printf("db: %s\n", dbName); + (void)printf("vgroup id: %d\n", vgroupId); if (count++ > 200) { - tmq_unsubscribe(tmq); + (void)tmq_unsubscribe(tmq); break; } @@ -1141,17 +1150,18 @@ TEST(clientCase, sub_db_test) { if (row == NULL) break; fields = taos_fetch_fields(pRes); + assert(fields != NULL); numOfFields = taos_field_count(pRes); precision = taos_result_precision(pRes); rows++; - taos_print_row(buf, row, fields, numOfFields); - printf("precision: %d, row content: %s\n", precision, buf); + (void)taos_print_row(buf, row, fields, numOfFields); + (void)printf("precision: %d, row content: %s\n", precision, buf); } taos_free_result(pRes); } } - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, tmq_commit) { @@ -1162,13 +1172,13 @@ TEST(clientCase, tmq_commit) { tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "false"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", "group_id_2"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set(conf, "enable.auto.commit", "false"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", "group_id_2"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); tmq_conf_destroy(conf); @@ -1176,10 +1186,10 @@ TEST(clientCase, tmq_commit) { char topicName[128] = "tp"; // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, topicName); + (void)tmq_list_append(topicList, topicName); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); int32_t totalRows = 0; @@ -1191,11 +1201,11 @@ TEST(clientCase, tmq_commit) { int32_t code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1210,13 +1220,13 @@ TEST(clientCase, tmq_commit) { int64_t position = tmq_position(tmq, topicName, pa->vgId); std::cout << "position vgId:" << pa->vgId << ", position:" << position << std::endl; - tmq_offset_seek(tmq, topicName, pa->vgId, 1); + (void)tmq_offset_seek(tmq, topicName, pa->vgId, 1); position = tmq_position(tmq, topicName, pa->vgId); std::cout << "after seek 1, position vgId:" << pa->vgId << " position:" << position << std::endl; } while (1) { - printf("start to poll\n"); + (void)printf("start to poll\n"); TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { printSubResults(pRes, &totalRows); @@ -1224,13 +1234,13 @@ TEST(clientCase, tmq_commit) { break; } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); for(int i = 0; i < numOfAssign; i++) { int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); std::cout << "committed vgId:" << pAssign[i].vgId << " , committed:" << committed << std::endl; if(committed > 0){ int32_t code = tmq_commit_offset_sync(tmq, topicName, pAssign[i].vgId, 4); - printf("tmq_commit_offset_sync vgId:%d, offset:4, code:%d\n", pAssign[i].vgId, code); + (void)printf("tmq_commit_offset_sync vgId:%d, offset:4, code:%d\n", pAssign[i].vgId, code); int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); std::cout << "after tmq_commit_offset_sync, committed vgId:" << pAssign[i].vgId << ", committed:" << committed @@ -1246,9 +1256,9 @@ TEST(clientCase, tmq_commit) { tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } namespace { void doPrintInfo(tmq_topic_assignment* pa, int32_t index) { @@ -1264,24 +1274,25 @@ TEST(clientCase, td_25129) { tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "false"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", "group_id_2"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set(conf, "enable.auto.commit", "false"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", "group_id_2"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); char topicName[128] = "tp"; // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, topicName); + (void)tmq_list_append(topicList, topicName); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1298,11 +1309,11 @@ TEST(clientCase, td_25129) { int32_t code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1315,11 +1326,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1331,11 +1342,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1345,7 +1356,7 @@ TEST(clientCase, td_25129) { } while (1) { - printf("start to poll\n"); + (void)printf("start to poll\n"); TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { char buf[128]; @@ -1354,19 +1365,19 @@ TEST(clientCase, td_25129) { // const char* dbName = tmq_get_db_name(pRes); // int32_t vgroupId = tmq_get_vgroup_id(pRes); // -// printf("topic: %s\n", topicName); -// printf("db: %s\n", dbName); -// printf("vgroup id: %d\n", vgroupId); +// (void)printf("topic: %s\n", topicName); +// (void)printf("db: %s\n", dbName); +// (void)printf("vgroup id: %d\n", vgroupId); printSubResults(pRes, &totalRows); code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1375,9 +1386,9 @@ TEST(clientCase, td_25129) { } } else { for(int i = 0; i < numOfAssign; i++) { - tmq_offset_seek(tmq, topicName, pAssign[i].vgId, pAssign[i].currentOffset); + (void)tmq_offset_seek(tmq, topicName, pAssign[i].vgId, pAssign[i].currentOffset); } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); break; } @@ -1398,11 +1409,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1411,13 +1422,13 @@ TEST(clientCase, td_25129) { } tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, sub_tb_test) { - taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + (void)taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -1426,27 +1437,28 @@ TEST(clientCase, sub_tb_test) { int32_t ts = taosGetTimestampMs()%INT32_MAX; char consumerGroupid[128] = {0}; - sprintf(consumerGroupid, "group_id_%d", ts); + (void)sprintf(consumerGroupid, "group_id_%d", ts); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", consumerGroupid); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "false"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", consumerGroupid); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "false"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "t1"); + (void)tmq_list_append(topicList, "t1"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1463,36 +1475,36 @@ TEST(clientCase, sub_tb_test) { int32_t code = tmq_get_topic_assignment(tmq, "t1", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); - tmq_consumer_close(tmq); + (void)printf("error occurs:%s\n", tmq_err2str(code)); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } - tmq_offset_seek(tmq, "t1", pAssign[0].vgId, 4); + (void)tmq_offset_seek(tmq, "t1", pAssign[0].vgId, 4); code = tmq_get_topic_assignment(tmq, "t1", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); - tmq_consumer_close(tmq); + (void)printf("error occurs:%s\n", tmq_err2str(code)); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } while (1) { TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { - char buf[128]; + char buf[128] = {0}; const char* topicName = tmq_get_topic_name(pRes); // const char* dbName = tmq_get_db_name(pRes); // int32_t vgroupId = tmq_get_vgroup_id(pRes); // -// printf("topic: %s\n", topicName); -// printf("db: %s\n", dbName); -// printf("vgroup id: %d\n", vgroupId); +// (void)printf("topic: %s\n", topicName); +// (void)printf("db: %s\n", dbName); +// (void)printf("vgroup id: %d\n", vgroupId); printSubResults(pRes, &totalRows); } else { @@ -1500,7 +1512,7 @@ TEST(clientCase, sub_tb_test) { // break; } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); if (pRes != NULL) { taos_free_result(pRes); // if ((++count) > 1) { @@ -1510,12 +1522,12 @@ TEST(clientCase, sub_tb_test) { break; } - tmq_offset_seek(tmq, "topic_t1", pAssign[0].vgId, pAssign[0].begin); + (void)tmq_offset_seek(tmq, "topic_t1", pAssign[0].vgId, pAssign[0].begin); } - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, sub_tb_mt_test) { @@ -1524,17 +1536,17 @@ TEST(clientCase, sub_tb_mt_test) { char *ip = NULL; int port = 0; char key[512] = {0}; - snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port); + (void)snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port); - taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + (void)taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TdThread qid[20] = {0}; for (int32_t i = 0; i < 1; ++i) { - taosThreadCreate(&qid[i], NULL, doConsumeData, NULL); + (void)taosThreadCreate(&qid[i], NULL, doConsumeData, NULL); } for (int32_t i = 0; i < 4; ++i) { - taosThreadJoin(qid[i], NULL); + (void)taosThreadJoin(qid[i], NULL); } } @@ -1552,12 +1564,12 @@ TEST(clientCase, sub_tb_mt_test) { // } // int ret = snprintf(buf + len, size - len, "%s", db); // if (ret < 0) { -// printf("snprintf failed, buf:%s, ret:%d", buf, ret); +// (void)printf("snprintf failed, buf:%s, ret:%d", buf, ret); // break; // } // len += ret; // if (len >= size){ -// printf("dbList is truncated, buf:%s, len:%d", buf, len); +// (void)printf("dbList is truncated, buf:%s, len:%d", buf, len); // break; // } // } diff --git a/source/common/src/tcol.c b/source/common/src/tcol.c index a949d0793a..17972c6777 100644 --- a/source/common/src/tcol.c +++ b/source/common/src/tcol.c @@ -238,7 +238,7 @@ const char* columnLevelStr(uint8_t type) { bool checkColumnEncode(char encode[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(encode)) return true; - strtolower(encode, encode); + (void)strtolower(encode, encode); for (int i = 0; i < supportedEncodeNum; ++i) { if (0 == strcmp((const char*)encode, supportedEncode[i])) { return true; @@ -255,7 +255,7 @@ bool checkColumnEncodeOrSetDefault(uint8_t type, char encode[TSDB_CL_COMPRESS_OP } bool checkColumnCompress(char compress[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(compress)) return true; - strtolower(compress, compress); + (void)strtolower(compress, compress); for (int i = 0; i < supportedCompressNum; ++i) { if (0 == strcmp((const char*)compress, supportedCompress[i])) { return true; @@ -273,7 +273,7 @@ bool checkColumnCompressOrSetDefault(uint8_t type, char compress[TSDB_CL_COMPRES } bool checkColumnLevel(char level[TSDB_CL_COMPRESS_OPTION_LEN]) { if (0 == strlen(level)) return true; - strtolower(level, level); + (void)strtolower(level, level); if (1 == strlen(level)) { if ('h' == level[0] || 'm' == level[0] || 'l' == level[0]) return true; } else { diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c17b8ef526..c5c0553abe 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1764,23 +1764,33 @@ int32_t tDeserializeSUpdateIpWhite(void *buf, int32_t bufLen, SUpdateIpWhite *pR return 0; } void tFreeSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { - for (int i = 0; i < pReq->numOfUser; i++) { - SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i]; - taosMemoryFree(pUserWhite->pIpRanges); + if (pReq == NULL) return; + + if (pReq->pUserIpWhite) { + for (int i = 0; i < pReq->numOfUser; i++) { + SUpdateUserIpWhite *pUserWhite = &pReq->pUserIpWhite[i]; + taosMemoryFree(pUserWhite->pIpRanges); + } } taosMemoryFree(pReq->pUserIpWhite); - // impl later return; } -SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { +int32_t cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq, SUpdateIpWhite **pUpdateMsg) { + int32_t code = 0; + if (pReq == NULL) { + return 0; + } SUpdateIpWhite *pClone = taosMemoryCalloc(1, sizeof(SUpdateIpWhite)); - if (pClone == NULL) return NULL; + if (pClone == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } pClone->numOfUser = pReq->numOfUser; pClone->ver = pReq->ver; - if ((pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser)) == NULL) { + pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser); + if (pClone->pUserIpWhite == NULL) { taosMemoryFree(pClone); - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } for (int i = 0; i < pReq->numOfUser; i++) { @@ -1792,17 +1802,21 @@ SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) { pNew->numOfRange = pOld->numOfRange; int32_t sz = pOld->numOfRange * sizeof(SIpV4Range); - if ((pNew->pIpRanges = taosMemoryCalloc(1, sz)) == NULL) { - for (int j = 0; j < i; j++) { - taosMemoryFree(pClone->pUserIpWhite[j].pIpRanges); - } - taosMemoryFree(pClone->pUserIpWhite); - taosMemoryFree(pClone); - return NULL; + pNew->pIpRanges = taosMemoryCalloc(1, sz); + if (pNew->pIpRanges == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; } memcpy(pNew->pIpRanges, pOld->pIpRanges, sz); } - return pClone; +_return: + if (code < 0) { + tFreeSUpdateIpWhiteReq(pClone); + taosMemoryFree(pClone); + } else { + *pUpdateMsg = pClone; + } + return code; } int32_t tSerializeRetrieveIpWhite(void *buf, int32_t bufLen, SRetrieveIpWhiteReq *pReq) { SEncoder encoder = {0}; @@ -7342,6 +7356,7 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { if (tEncodeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1; if (tEncodeI8(&encoder, pReq->enableReplay) < 0) return -1; if (tEncodeI8(&encoder, pReq->sourceExcluded) < 0) return -1; + if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1; tEndEncode(&encoder); @@ -7353,7 +7368,6 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { pHead->vgId = htonl(pReq->head.vgId); pHead->contLen = htonl(tlen + headLen); } - if (tEncodeI8(&encoder, pReq->enableBatchMeta) < 0) return -1; return tlen + headLen; } @@ -9180,7 +9194,7 @@ int32_t tDecodeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffsetVal) { return 0; } -int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { +void tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { if (pVal->type == TMQ_OFFSET__RESET_NONE) { (void)snprintf(buf, maxLen, "none"); } else if (pVal->type == TMQ_OFFSET__RESET_EARLIEST) { @@ -9192,7 +9206,7 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) { if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) { char *tmp = taosMemoryCalloc(1, pVal->primaryKey.nData + 1); - if (tmp == NULL) return terrno; + if (tmp == NULL) return; (void)memcpy(tmp, pVal->primaryKey.pData, pVal->primaryKey.nData); (void)snprintf(buf, maxLen, "tsdb:%" PRId64 "|%" PRId64 ",pk type:%d,val:%s", pVal->uid, pVal->ts, pVal->primaryKey.type, tmp); @@ -9202,8 +9216,6 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { pVal->primaryKey.type, pVal->primaryKey.val); } } - - return 0; } bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { @@ -9226,16 +9238,17 @@ bool tOffsetEqual(const STqOffsetVal *pLeft, const STqOffsetVal *pRight) { return false; } -int32_t tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { +void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) { tOffsetDestroy(pLeft); *pLeft = *pRight; if (IS_VAR_DATA_TYPE(pRight->primaryKey.type)) { - if ((pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData)) == NULL) { - return terrno; + pLeft->primaryKey.pData = taosMemoryMalloc(pRight->primaryKey.nData); + if (pLeft->primaryKey.pData == NULL) { + uError("failed to allocate memory for offset"); + return; } (void)memcpy(pLeft->primaryKey.pData, pRight->primaryKey.pData, pRight->primaryKey.nData); } - return 0; } void tOffsetDestroy(void *param) { diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 1dc4a6f9ba..942255cd7c 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -68,7 +68,7 @@ bool tdSTSRowIterFetch(STSRowIter *pIter, col_id_t colId, col_type_t colType, SC return false; } } - tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal); + (void)tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal); ++pIter->colIdx; } else if (TD_IS_KV_ROW(pIter->pRow)) { return tdSTSRowIterGetKvVal(pIter, colId, &pIter->kvIdx, pVal); diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index f7398befb1..e6e065756f 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -260,7 +260,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { return code; } - taosThreadMutexLock(&pDnode->mutex); + (void)taosThreadMutexLock(&pDnode->mutex); SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); dInfo("node:%s, start to create", pWrapper->name); @@ -277,7 +277,7 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { pWrapper->required = true; } - taosThreadMutexUnlock(&pDnode->mutex); + (void)taosThreadMutexUnlock(&pDnode->mutex); return code; } @@ -316,7 +316,7 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) { dInfo("node:%s, catched up leader, continue to process alter-node-type-request", pWrapper->name); - taosThreadMutexLock(&pDnode->mutex); + (void)taosThreadMutexLock(&pDnode->mutex); dInfo("node:%s, stopping node", pWrapper->name); dmStopNode(pWrapper); @@ -325,7 +325,7 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) { pWrapper = &pDnode->wrappers[ntype]; if (taosMkDir(pWrapper->path) != 0) { - taosThreadMutexUnlock(&pDnode->mutex); + (void)taosThreadMutexUnlock(&pDnode->mutex); code = terrno; dError("failed to create dir:%s since %s", pWrapper->path, tstrerror(code)); return code; @@ -347,7 +347,7 @@ static int32_t dmProcessAlterNodeTypeReq(EDndNodeType ntype, SRpcMsg *pMsg) { pWrapper->required = true; } - taosThreadMutexUnlock(&pDnode->mutex); + (void)taosThreadMutexUnlock(&pDnode->mutex); return code; } @@ -375,7 +375,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { return terrno = code; } - taosThreadMutexLock(&pDnode->mutex); + (void)taosThreadMutexLock(&pDnode->mutex); SMgmtInputOpt input = dmBuildMgmtInputOpt(pWrapper); dInfo("node:%s, start to drop", pWrapper->name); @@ -395,7 +395,7 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { dmCloseNode(pWrapper); taosRemoveDir(pWrapper->path); } - taosThreadMutexUnlock(&pDnode->mutex); + (void)taosThreadMutexUnlock(&pDnode->mutex); return code; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index f0fa497eec..0c04d50927 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -65,10 +65,11 @@ static int32_t dmConvertErrCode(tmsg_t msgType, int32_t code) { return code; } static void dmUpdateRpcIpWhite(SDnodeData *pData, void *pTrans, SRpcMsg *pRpc) { + int32_t code = 0; SUpdateIpWhite ipWhite = {0}; // aosMemoryCalloc(1, sizeof(SUpdateIpWhite)); tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, &ipWhite); - rpcSetIpWhite(pTrans, &ipWhite); + code = rpcSetIpWhite(pTrans, &ipWhite); pData->ipWhiteVer = ipWhite.ver; tFreeSUpdateIpWhiteReq(&ipWhite); diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index d6647f88f2..2e352915d8 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -224,7 +224,7 @@ int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeOb terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -252,7 +252,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S code = TSDB_CODE_OUT_OF_MEMORY; TAOS_RETURN(code); } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -330,7 +330,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; char obj[33] = {0}; - sprintf(obj, "%d", createReq.dnodeId); + (void)sprintf(obj, "%d", createReq.dnodeId); auditRecord(pReq, pMnode->clusterId, "createQnode", "", obj, createReq.sql, createReq.sqlLen); _OVER: @@ -383,7 +383,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn code = TSDB_CODE_OUT_OF_MEMORY; TAOS_RETURN(code); } - tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); + (void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq); STransAction action = {0}; action.epSet = mndGetDnodeEpset(pDnode); @@ -459,7 +459,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; char obj[33] = {0}; - sprintf(obj, "%d", dropReq.dnodeId); + (void)sprintf(obj, "%d", dropReq.dnodeId); auditRecord(pReq, pMnode->clusterId, "dropQnode", "", obj, dropReq.sql, dropReq.sqlLen); @@ -531,7 +531,7 @@ static int32_t mndProcessQnodeListReq(SRpcMsg *pReq) { goto _OVER; } - tSerializeSQnodeListRsp(pRsp, rspLen, &qlistRsp); + (void)tSerializeSQnodeListRsp(pRsp, rspLen, &qlistRsp); pReq->info.rspLen = rspLen; pReq->info.rsp = pRsp; @@ -556,15 +556,15 @@ static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false); char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)ep, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)ep, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); numOfRows++; sdbRelease(pSdb, pObj); diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index 7c86b9aa74..c743aafd13 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -27,7 +27,7 @@ int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg) { void mndPostProcessQueryMsg(SRpcMsg *pMsg) { if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) return; SMnode *pMnode = pMsg->info.node; - qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg); + (void)qWorkerAbortPreprocessQueryMsg(pMnode->pQuery, pMsg); } int32_t mndProcessQueryMsg(SRpcMsg *pMsg, SQueueInfo* pInfo) { @@ -134,7 +134,10 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) { rsp.msgLen = reqMsg.info.rspLen; rsp.msg = reqMsg.info.rsp; - taosArrayPush(batchRsp.pRsps, &rsp); + if (taosArrayPush(batchRsp.pRsps, &rsp) == NULL) { + mError("msg:%p, failed to put array since %s, app:%p type:%s", pMsg, terrstr(), pMsg->info.ahandle, + TMSG_INFO(pMsg->msgType)); + } } rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp); diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 3593e21e11..3f03102a7a 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -115,7 +115,7 @@ int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) { } else { pInfo->type = TASK_OUTPUT__TABLE; pInfo->tbSink.stbUid = pStream->targetStbUid; - memcpy(pInfo->tbSink.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); + (void)memcpy(pInfo->tbSink.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); pInfo->tbSink.pSchemaWrapper = tCloneSSchemaWrapper(&pStream->outputSchema); if (pInfo->tbSink.pSchemaWrapper == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -145,7 +145,7 @@ int32_t mndAddDispatcherForInternalTask(SMnode* pMnode, SStreamObj* pStream, SAr int32_t numOfSinkNodes = taosArrayGetSize(pSinkNodeList); if (isShuffle) { - memcpy(pTask->outputInfo.shuffleDispatcher.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); + (void)memcpy(pTask->outputInfo.shuffleDispatcher.stbFullName, pStream->targetSTbName, TSDB_TABLE_FNAME_LEN); SArray* pVgs = pTask->outputInfo.shuffleDispatcher.dbInfo.pVgroupInfos; int32_t numOfVgroups = taosArrayGetSize(pVgs); @@ -363,10 +363,14 @@ static int32_t buildSourceTask(SStreamObj* pStream, SEpSet* pEpset, bool isFillh static void addNewTaskList(SStreamObj* pStream) { SArray* pTaskList = taosArrayInit(0, POINTER_BYTES); - taosArrayPush(pStream->tasks, &pTaskList); + if (taosArrayPush(pStream->tasks, &pTaskList) == NULL) { + mError("failed to put array"); + } if (pStream->conf.fillHistory) { pTaskList = taosArrayInit(0, POINTER_BYTES); - taosArrayPush(pStream->pHTasksList, &pTaskList); + if (taosArrayPush(pStream->pHTasksList, &pTaskList) == NULL) { + mError("failed to put array"); + } } } @@ -584,10 +588,15 @@ static int32_t addSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset) } static void bindTaskToSinkTask(SStreamObj* pStream, SMnode* pMnode, SArray* pSinkTaskList, SStreamTask* task) { - mndAddDispatcherForInternalTask(pMnode, pStream, pSinkTaskList, task); + int32_t code = 0; + if ((code = mndAddDispatcherForInternalTask(pMnode, pStream, pSinkTaskList, task)) != 0) { + mError("failed bind task to sink task since %s", tstrerror(code)); + } for (int32_t k = 0; k < taosArrayGetSize(pSinkTaskList); k++) { SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, k); - streamTaskSetUpstreamInfo(pSinkTask, task); + if ((code = streamTaskSetUpstreamInfo(pSinkTask, task)) != 0) { + mError("failed bind task to sink task since %s", tstrerror(code)); + } } mDebug("bindTaskToSinkTask taskId:%s to sink task list", task->id.idStr); } @@ -604,6 +613,7 @@ static void bindAggSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks) { } static void bindSourceSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks, bool hasExtraSink) { + int32_t code = 0; SArray* pSinkTaskList = taosArrayGetP(tasks, SINK_NODE_LEVEL); SArray* pSourceTaskList = taosArrayGetP(tasks, hasExtraSink ? SINK_NODE_LEVEL + 1 : SINK_NODE_LEVEL); @@ -614,12 +624,15 @@ static void bindSourceSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks, b if (hasExtraSink) { bindTaskToSinkTask(pStream, pMnode, pSinkTaskList, pSourceTask); } else { - mndSetSinkTaskInfo(pStream, pSourceTask); + if ((code = mndSetSinkTaskInfo(pStream, pSourceTask)) != 0) { + mError("failed bind task to sink task since %s", tstrerror(code)); + } } } } static void bindTwoLevel(SArray* tasks, int32_t begin, int32_t end) { + int32_t code = 0; size_t size = taosArrayGetSize(tasks); ASSERT(size >= 2); SArray* pDownTaskList = taosArrayGetP(tasks, size - 1); @@ -631,7 +644,9 @@ static void bindTwoLevel(SArray* tasks, int32_t begin, int32_t end) { SStreamTask* pUpTask = taosArrayGetP(pUpTaskList, i); pUpTask->info.selfChildId = i - begin; streamTaskSetFixedDownstreamInfo(pUpTask, *pDownTask); - streamTaskSetUpstreamInfo(*pDownTask, pUpTask); + if ((code = streamTaskSetUpstreamInfo(*pDownTask, pUpTask)) != 0) { + mError("failed bind task to sink task since %s", tstrerror(code)); + } } mDebug("bindTwoLevel task list(%d-%d) to taskId:%s", begin, end - 1, (*(pDownTask))->id.idStr); } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 687f21845e..6989e1e4f1 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -158,7 +158,7 @@ static SShowObj *mndCreateShowObj(SMnode *pMnode, SRetrieveTableReq *pReq) { showObj.id = showId; showObj.pMnode = pMnode; showObj.type = convertToRetrieveType(pReq->tb, tListLen(pReq->tb)); - memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN); + (void)memcpy(showObj.db, pReq->db, TSDB_DB_FNAME_LEN); tstrncpy(showObj.filterTb, pReq->filterTb, TSDB_TABLE_NAME_LEN); int32_t keepTime = tsShellActivityTimer * 6 * 1000; @@ -270,9 +270,9 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { mDebug("show:0x%" PRIx64 ", start retrieve data, type:%d", pShow->id, pShow->type); if (retrieveReq.user[0] != 0) { - memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN); + (void)memcpy(pReq->info.conn.user, retrieveReq.user, TSDB_USER_LEN); } else { - memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1); + (void)memcpy(pReq->info.conn.user, TSDB_DEFAULT_USER, strlen(TSDB_DEFAULT_USER) + 1); } code = -1; if (retrieveReq.db[0] && @@ -303,10 +303,10 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { idata.info.bytes = p->bytes; idata.info.type = p->type; idata.info.colId = p->colId; - blockDataAppendColInfo(pBlock, &idata); + TAOS_CHECK_RETURN(blockDataAppendColInfo(pBlock, &idata)); } - blockDataEnsureCapacity(pBlock, rowsToRead); + TAOS_CHECK_RETURN(blockDataEnsureCapacity(pBlock, rowsToRead)); if (mndCheckRetrieveFinished(pShow)) { mDebug("show:0x%" PRIx64 ", read finished, numOfRows:%d", pShow->id, pShow->numOfRows); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 70d0b858f6..89f3c6e253 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -212,8 +212,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) { mndTransRefresh(pMnode, pTrans); sdbSetApplyInfo(pMnode->pSdb, pMeta->index, pMeta->term, pMeta->lastConfigIndex); - sdbWriteFile(pMnode->pSdb, tsMndSdbWriteDelta); - code = 0; + code = sdbWriteFile(pMnode->pSdb, tsMndSdbWriteDelta); _OUT: if (pTrans) mndReleaseTrans(pMnode, pTrans); @@ -222,7 +221,7 @@ _OUT: static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId == 0) { goto _OUT; } @@ -232,7 +231,7 @@ static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = code; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); if (pMgmt->errCode != 0) { mError("trans:%d, failed to propose since %s, post sem", transId, tstrerror(pMgmt->errCode)); @@ -241,7 +240,7 @@ static int32_t mndPostMgmtCode(SMnode *pMnode, int32_t code) { } _OUT: - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); return 0; } @@ -304,7 +303,7 @@ void mndRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) { } else { mInfo("vgId:1, sync restore finished"); } - mndRefreshUserIpWhiteList(pMnode); + (void)mndRefreshUserIpWhiteList(pMnode); ASSERT(commitIdx == mndSyncAppliedIndex(pFsm)); } @@ -350,16 +349,16 @@ static void mndBecomeFollower(const SSyncFSM *pFsm) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; mInfo("vgId:1, become follower"); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, become follower and post sem, trans:%d, failed to propose since not leader", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } static void mndBecomeLearner(const SSyncFSM *pFsm) { @@ -367,16 +366,16 @@ static void mndBecomeLearner(const SSyncFSM *pFsm) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; mInfo("vgId:1, become learner"); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, become learner and post sem, trans:%d, failed to propose since not leader", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; pMgmt->errCode = TSDB_CODE_SYN_NOT_LEADER; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } static void mndBecomeLeader(const SSyncFSM *pFsm) { @@ -435,12 +434,12 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) { int32_t mndInitSync(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexInit(&pMgmt->lock, NULL); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexInit(&pMgmt->lock, NULL); + (void)taosThreadMutexLock(&pMgmt->lock); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); SSyncInfo syncInfo = { .snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT, @@ -477,7 +476,7 @@ int32_t mndInitSync(SMnode *pMnode) { } int32_t code = 0; - tsem_init(&pMgmt->syncSem, 0, 0); + (void)tsem_init(&pMgmt->syncSem, 0, 0); pMgmt->sync = syncOpen(&syncInfo, true); if (pMgmt->sync <= 0) { if (terrno != 0) code = terrno; @@ -495,15 +494,15 @@ void mndCleanupSync(SMnode *pMnode) { syncStop(pMgmt->sync); mInfo("mnode-sync is stopped, id:%" PRId64, pMgmt->sync); - tsem_destroy(&pMgmt->syncSem); - taosThreadMutexDestroy(&pMgmt->lock); + (void)tsem_destroy(&pMgmt->syncSem); + (void)taosThreadMutexDestroy(&pMgmt->lock); memset(pMgmt, 0, sizeof(SSyncMgmt)); } void mndSyncCheckTimeout(SMnode *pMnode) { mTrace("check sync timeout"); SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { int32_t curSec = taosGetTimestampSec(); int32_t delta = curSec - pMgmt->transSec; @@ -515,7 +514,7 @@ void mndSyncCheckTimeout(SMnode *pMnode) { pMgmt->transSeq = 0; terrno = TSDB_CODE_SYN_TIMEOUT; pMgmt->errCode = TSDB_CODE_SYN_TIMEOUT; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } else { mDebug("trans:%d, waiting for sync confirm, start:%d cur:%d delta:%d seq:%" PRId64, pMgmt->transId, pMgmt->transSec, curSec, curSec - pMgmt->transSec, pMgmt->transSeq); @@ -523,7 +522,7 @@ void mndSyncCheckTimeout(SMnode *pMnode) { } else { // mTrace("check sync timeout msg, no trans waiting for confirm"); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { @@ -536,12 +535,12 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { if (req.pCont == NULL) return TSDB_CODE_OUT_OF_MEMORY; memcpy(req.pCont, pRaw, req.contLen); - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); pMgmt->errCode = 0; if (pMgmt->transId != 0) { mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId); - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); rpcFreeCont(req.pCont); TAOS_RETURN(TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED); } @@ -555,23 +554,24 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { if (code == 0) { mInfo("trans:%d, is proposing and wait sem, seq:%" PRId64, transId, seq); pMgmt->transSeq = seq; - taosThreadMutexUnlock(&pMgmt->lock); - tsem_wait(&pMgmt->syncSem); + (void)taosThreadMutexUnlock(&pMgmt->lock); + (void)tsem_wait(&pMgmt->syncSem); } else if (code > 0) { mInfo("trans:%d, confirm at once since replica is 1, continue execute", transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); - sdbWriteWithoutFree(pMnode->pSdb, pRaw); - sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID); - code = 0; + (void)taosThreadMutexUnlock(&pMgmt->lock); + code = sdbWriteWithoutFree(pMnode->pSdb, pRaw); + if (code == 0) { + sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID); + } } else { mError("trans:%d, failed to proposed since %s", transId, terrstr()); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->transSeq = 0; - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); if (terrno == 0) { terrno = TSDB_CODE_APP_ERROR; } @@ -600,15 +600,15 @@ void mndSyncStart(SMnode *pMnode) { void mndSyncStop(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); if (pMgmt->transId != 0) { mInfo("vgId:1, is stopped and post sem, trans:%d", pMgmt->transId); pMgmt->transId = 0; pMgmt->transSec = 0; pMgmt->errCode = TSDB_CODE_APP_IS_STOPPING; - tsem_post(&pMgmt->syncSem); + (void)tsem_post(&pMgmt->syncSem); } - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); } bool mndIsLeader(SMnode *pMnode) { diff --git a/source/dnode/mnode/impl/src/mndTelem.c b/source/dnode/mnode/impl/src/mndTelem.c index ac379a9f94..f766c00f7d 100644 --- a/source/dnode/mnode/impl/src/mndTelem.c +++ b/source/dnode/mnode/impl/src/mndTelem.c @@ -70,16 +70,16 @@ static void mndBuildRuntimeInfo(SMnode* pMnode, SJson* pJson) { SMnodeStat mstat = {0}; mndGetStat(pMnode, &mstat); - tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode); - tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode); - tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup); - tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase); - tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable); - tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable); - tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn); - tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints); - tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage); - tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage); + (void)tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode); + (void)tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode); + (void)tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup); + (void)tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase); + (void)tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable); + (void)tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable); + (void)tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn); + (void)tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints); + (void)tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage); + (void)tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage); } static char* mndBuildTelemetryReport(SMnode* pMnode) { @@ -90,29 +90,29 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) { if (pJson == NULL) return NULL; char clusterName[64] = {0}; - mndGetClusterName(pMnode, clusterName, sizeof(clusterName)); - tjsonAddStringToObject(pJson, "instanceId", clusterName); - tjsonAddDoubleToObject(pJson, "reportVersion", 1); + if ((terrno = mndGetClusterName(pMnode, clusterName, sizeof(clusterName))) != 0) return NULL; + (void)tjsonAddStringToObject(pJson, "instanceId", clusterName); + (void)tjsonAddDoubleToObject(pJson, "reportVersion", 1); if (taosGetOsReleaseName(tmp, NULL, NULL, sizeof(tmp)) == 0) { - tjsonAddStringToObject(pJson, "os", tmp); + (void)tjsonAddStringToObject(pJson, "os", tmp); } float numOfCores = 0; if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) { - tjsonAddStringToObject(pJson, "cpuModel", tmp); - tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores); + (void)tjsonAddStringToObject(pJson, "cpuModel", tmp); + (void)tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores); } else { - tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores); + (void)tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores); } snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB); - tjsonAddStringToObject(pJson, "memory", tmp); + (void)tjsonAddStringToObject(pJson, "memory", tmp); - tjsonAddStringToObject(pJson, "version", version); - tjsonAddStringToObject(pJson, "buildInfo", buildinfo); - tjsonAddStringToObject(pJson, "gitInfo", gitinfo); - tjsonAddStringToObject(pJson, "email", pMgmt->email); + (void)tjsonAddStringToObject(pJson, "version", version); + (void)tjsonAddStringToObject(pJson, "buildInfo", buildinfo); + (void)tjsonAddStringToObject(pJson, "gitInfo", gitinfo); + (void)tjsonAddStringToObject(pJson, "email", pMgmt->email); mndBuildRuntimeInfo(pMnode, pJson); @@ -126,9 +126,9 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) { STelemMgmt* pMgmt = &pMnode->telemMgmt; if (!tsEnableTelem) return 0; - taosThreadMutexLock(&pMgmt->lock); + (void)taosThreadMutexLock(&pMgmt->lock); char* pCont = mndBuildTelemetryReport(pMnode); - taosThreadMutexUnlock(&pMgmt->lock); + (void)taosThreadMutexUnlock(&pMgmt->lock); if (pCont != NULL) { if (taosSendHttpReport(tsTelemServer, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) { @@ -142,10 +142,12 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) { } int32_t mndInitTelem(SMnode* pMnode) { + int32_t code = 0; STelemMgmt* pMgmt = &pMnode->telemMgmt; - taosThreadMutexInit(&pMgmt->lock, NULL); - taosGetEmail(pMgmt->email, sizeof(pMgmt->email)); + (void)taosThreadMutexInit(&pMgmt->lock, NULL); + if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0) + mWarn("failed to get email since %s", tstrerror(code)); mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer); return 0; @@ -153,5 +155,5 @@ int32_t mndInitTelem(SMnode* pMnode) { void mndCleanupTelem(SMnode* pMnode) { STelemMgmt* pMgmt = &pMnode->telemMgmt; - taosThreadMutexDestroy(&pMgmt->lock); + (void)taosThreadMutexDestroy(&pMgmt->lock); } diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index a596233364..8ed3f66009 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -376,7 +376,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) { for (int32_t i = 0; i < arbgroupIdNum; ++i) { int32_t arbGroupId = 0; SDB_GET_INT32(pRaw, dataPos, &arbGroupId, _OVER) - taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0); + if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER; } SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER) @@ -461,7 +461,7 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) { mInfo("trans:%d, perform insert action, row:%p stage:%s, callfunc:1, startFunc:%d", pTrans->id, pTrans, mndTransStr(pTrans->stage), pTrans->startFunc); - taosThreadMutexInit(&pTrans->mutex, NULL); + (void)taosThreadMutexInit(&pTrans->mutex, NULL); if (pTrans->startFunc > 0) { TransCbFp fp = mndTransGetCbFp(pTrans->startFunc); @@ -616,7 +616,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo)); pTrans->mTraceId = pReq ? TRACE_GET_ROOTID(&pReq->info.traceId) : tGenIdPI64(); taosInitRWLatch(&pTrans->lockRpcArray); - taosThreadMutexInit(&pTrans->mutex, NULL); + (void)taosThreadMutexInit(&pTrans->mutex, NULL); if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL || pTrans->pRpcArray == NULL) { @@ -627,7 +627,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict, } if (pReq != NULL) { - taosArrayPush(pTrans->pRpcArray, &pReq->info); + if (taosArrayPush(pTrans->pRpcArray, &pReq->info) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } pTrans->originRpcType = pReq->msgType; } @@ -765,7 +768,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) } void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId) { - taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0); + (void)taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0); } void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; } @@ -1148,13 +1151,13 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { } else if (pTrans->originRpcType == TDMT_MND_CREATE_STB) { void *pCont = NULL; int32_t contLen = 0; - if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen) != 0) { + if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen)) { mndTransSetRpcRsp(pTrans, pCont, contLen); } } else if (pTrans->originRpcType == TDMT_MND_CREATE_INDEX) { void *pCont = NULL; int32_t contLen = 0; - if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen) != 0) { + if (0 == mndBuildSMCreateStbRsp(pMnode, pTrans->dbname, pTrans->stbname, &pCont, &contLen)) { mndTransSetRpcRsp(pTrans, pCont, contLen); } } @@ -1505,9 +1508,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr pTrans->actionPos++; mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage), pAction->id); - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); code = mndTransSync(pMnode, pTrans); - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (code != 0) { pTrans->actionPos--; pTrans->code = terrno; @@ -1540,21 +1543,21 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (pTrans->stage == TRN_STAGE_REDO_ACTION) { code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->redoActions, topHalf); } - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); return code; } static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) { int32_t code = TSDB_CODE_ACTION_IN_PROGRESS; - taosThreadMutexLock(&pTrans->mutex); + (void)taosThreadMutexLock(&pTrans->mutex); if (pTrans->stage == TRN_STAGE_UNDO_ACTION) { code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->undoActions, topHalf); } - taosThreadMutexUnlock(&pTrans->mutex); + (void)taosThreadMutexUnlock(&pTrans->mutex); return code; } @@ -1894,7 +1897,7 @@ void mndTransPullup(SMnode *pMnode) { STrans *pTrans = NULL; pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans); if (pIter == NULL) break; - taosArrayPush(pArray, &pTrans->id); + (void)taosArrayPush(pArray, &pTrans->id); sdbRelease(pSdb, pTrans); } @@ -1925,36 +1928,36 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false); char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stage, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stage, false); char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)opername, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)opername, false); char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false); char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false); char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0}; char detail[TSDB_TRANS_ERROR_LEN + 1] = {0}; @@ -1970,7 +1973,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl } STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false); numOfRows++; sdbRelease(pSdb, pTrans); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 2095f80f0f..8bb2f11e7c 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -682,7 +682,7 @@ static void ipRangeToStr(SIpV4Range *range, char *buf) { struct in_addr addr; addr.s_addr = range->ip; - uv_inet_ntop(AF_INET, &addr, buf, 32); + (void)uv_inet_ntop(AF_INET, &addr, buf, 32); if (range->mask != 32) { (void)sprintf(buf + strlen(buf), "/%d", range->mask); } @@ -2188,7 +2188,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode mndReleaseDb(pMnode, pDb); TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code } - taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len); + (void)taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len); mndReleaseDb(pMnode, pDb); } else { taosHashClear(pNewUser->readDbs); @@ -2204,7 +2204,7 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode mndReleaseDb(pMnode, pDb); TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code } - taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len); + (void)taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len); mndReleaseDb(pMnode, pDb); } else { taosHashClear(pNewUser->writeDbs); @@ -2311,7 +2311,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { TAOS_CHECK_GOTO(mndAcquireUser(pMnode, alterReq.user, &pUser), &lino, _OVER); - mndAcquireUser(pMnode, pReq->info.conn.user, &pOperUser); + (void)mndAcquireUser(pMnode, pReq->info.conn.user, &pOperUser); if (pOperUser == NULL) { TAOS_CHECK_GOTO(TSDB_CODE_MND_NO_USER_FROM_CONN, &lino, _OVER); } @@ -2517,7 +2517,7 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) { mndTransDrop(pTrans); TAOS_RETURN(terrno); } - ipWhiteMgtRemove(pUser->user); + (void)ipWhiteMgtRemove(pUser->user); mndTransDrop(pTrans); TAOS_RETURN(0); @@ -2830,7 +2830,10 @@ static int32_t mndLoopHash(SHashObj *hash, char *priType, SSDataBlock *pBlock, i } if (nodesStringToNode(value, &pAst) == 0) { - nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen); + if (nodesNodeToSQL(pAst, *sql, bufSz, &sqlLen) != 0) { + sqlLen = 5; + (void)sprintf(*sql, "error"); + } nodesDestroyNode(pAst); } else { sqlLen = 5; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 30c11c09ce..57a7453eac 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -390,7 +390,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg return NULL; } - tSerializeSCreateVnodeReq(pReq, contLen, &createReq); + (void)tSerializeSCreateVnodeReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; } @@ -436,7 +436,7 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); + (void)tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -514,7 +514,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -587,7 +587,7 @@ static void *mndBuildCheckLearnCatchupReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); *pContLen = contLen; return pReq; } @@ -611,7 +611,7 @@ static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t v return NULL; } - tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); + (void)tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); *pContLen = contLen; return pReq; } @@ -639,7 +639,7 @@ static void *mndBuildAlterVnodeHashRangeReq(SMnode *pMnode, int32_t srcVgId, SVg return NULL; } - tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -664,7 +664,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb return NULL; } - tSerializeSDropVnodeReq(pReq, contLen, &dropReq); + (void)tSerializeSDropVnodeReq(pReq, contLen, &dropReq); *pContLen = contLen; return pReq; } @@ -699,7 +699,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 } if (online && pDnode->numOfSupportVnodes > 0) { - taosArrayPush(pArray, pDnode); + if (taosArrayPush(pArray, pDnode) == NULL) return false; } return true; } @@ -907,7 +907,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } epsetSort(&epset); @@ -930,7 +930,7 @@ SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } @@ -965,26 +965,26 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); SName name = {0}; char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); + (void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); + (void)tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)db, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); // default 3 replica, add 1 replica if move vnode for (int32_t i = 0; i < 4; ++i) { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); if (i < pVgroup->replica) { int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId; - colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); bool exist = false; bool online = false; @@ -1038,7 +1038,7 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); } else { colDataSetNULL(pColInfo, numOfRows); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); @@ -1048,19 +1048,19 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); int32_t cacheUsage = (int32_t)pVgroup->cacheUsage; - colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); // pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); // if (pDb == NULL || pDb->compactStartTime <= 0) { // colDataSetNULL(pColInfo, numOfRows); // } else { - // colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); + // (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); // } numOfRows++; @@ -1158,10 +1158,10 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); // db_name const char *dbname = mndGetDbStr(pVgroup->dbName); @@ -1172,7 +1172,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); } pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); // dnode is online? SDnodeObj *pDnode = mndAcquireDnode(pMnode, pGid->dnodeId); @@ -1186,18 +1186,18 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB ESyncState syncState = (isDnodeOnline) ? pGid->syncState : TAOS_SYNC_STATE_OFFLINE; STR_TO_VARSTR(buf, syncStr(syncState)); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); int64_t roleTimeMs = (isDnodeOnline) ? pGid->roleTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); int64_t startTimeMs = (isDnodeOnline) ? pGid->startTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); numOfRows++; sdbRelease(pSdb, pDnode); @@ -2452,7 +2452,7 @@ static void *mndBuildSForceBecomeFollowerReq(SMnode *pMnode, SVgObj *pVgroup, in pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); + (void)tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); *pContLen = contLen; return pReq; } @@ -3366,7 +3366,7 @@ static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgrou pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); + (void)tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); *pContLen = contLen; return pReq; } diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 84b3a21a8f..4c2213b700 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -31,7 +31,7 @@ Testbase MndTestTopic::test; void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { SCreateDbReq createReq = {0}; - strcpy(createReq.db, dbname); + (void)strcpy(createReq.db, dbname); createReq.numOfVgroups = 2; createReq.buffer = -1; createReq.pageSize = -1; @@ -53,7 +53,8 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); - tSerializeSCreateDbReq(pReq, contLen, &createReq); + assert(pReq != NULL); + (void)tSerializeSCreateDbReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; @@ -61,14 +62,15 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, int32_t* pContLen) { SCMCreateTopicReq createReq = {0}; - strcpy(createReq.name, topicName); + (void)strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; createReq.ast = NULL; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); - tSerializeSCMCreateTopicReq(pReq, contLen, &createReq); + assert(pReq != NULL); + (void)tSerializeSCMCreateTopicReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; @@ -76,11 +78,12 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen) { SMDropTopicReq dropReq = {0}; - strcpy(dropReq.name, topicName); + (void)strcpy(dropReq.name, topicName); int32_t contLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); void* pReq = rpcMallocCont(contLen); - tSerializeSMDropTopicReq(pReq, contLen, &dropReq); + assert(pReq != NULL); + (void)tSerializeSMDropTopicReq(pReq, contLen, &dropReq); *pContLen = contLen; return pReq; diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index c1d4ba7893..7244f2d7c9 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -46,7 +46,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { } for (ESdbType i = 0; i < SDB_MAX; ++i) { - taosThreadRwlockInit(&pSdb->locks[i], NULL); + (void)taosThreadRwlockInit(&pSdb->locks[i], NULL); pSdb->maxId[i] = 0; pSdb->tableVer[i] = 0; pSdb->keyTypes[i] = SDB_KEY_INT32; @@ -60,7 +60,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { pSdb->commitTerm = -1; pSdb->commitConfig = -1; pSdb->pMnode = pOption->pMnode; - taosThreadMutexInit(&pSdb->filelock, NULL); + (void)taosThreadMutexInit(&pSdb->filelock, NULL); mInfo("sdb init success"); return pSdb; } @@ -68,7 +68,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { void sdbCleanup(SSdb *pSdb) { mInfo("start to cleanup sdb"); - sdbWriteFile(pSdb, 0); + (void)sdbWriteFile(pSdb, 0); if (pSdb->currDir != NULL) { taosMemoryFreeClear(pSdb->currDir); @@ -99,14 +99,14 @@ void sdbCleanup(SSdb *pSdb) { taosHashClear(hash); taosHashCleanup(hash); - taosThreadRwlockDestroy(&pSdb->locks[i]); + (void)taosThreadRwlockDestroy(&pSdb->locks[i]); pSdb->hashObjs[i] = NULL; memset(&pSdb->locks[i], 0, sizeof(pSdb->locks[i])); mInfo("sdb table:%s is cleaned up", sdbTableName(i)); } - taosThreadMutexDestroy(&pSdb->filelock); + (void)taosThreadMutexDestroy(&pSdb->filelock); taosMemoryFree(pSdb); mInfo("sdb is cleaned up"); } @@ -188,19 +188,19 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config void sdbWriteLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start write lock:%p", type, pLock); - taosThreadRwlockWrlock(pLock); + (void)taosThreadRwlockWrlock(pLock); // mTrace("sdb table:%d stop write lock:%p", type, pLock); } void sdbReadLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start read lock:%p", type, pLock); - taosThreadRwlockRdlock(pLock); + (void)taosThreadRwlockRdlock(pLock); // mTrace("sdb table:%d stop read lock:%p", type, pLock); } void sdbUnLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d unlock:%p", type, pLock); - taosThreadRwlockUnlock(pLock); + (void)taosThreadRwlockUnlock(pLock); } diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 0952fbe7a3..6fb395e63f 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -258,7 +258,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { if (code != 0) { mError("failed to read sdb file:%s head since %s", file, tstrerror(code)); taosMemoryFree(pRaw); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -361,14 +361,14 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { pSdb->commitTerm, pSdb->commitConfig); _OVER: - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); sdbFreeRaw(pRaw); TAOS_RETURN(code); } int32_t sdbReadFile(SSdb *pSdb) { - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); sdbResetData(pSdb); int32_t code = sdbReadFileImp(pSdb); @@ -377,7 +377,7 @@ int32_t sdbReadFile(SSdb *pSdb) { sdbResetData(pSdb); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -404,7 +404,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { code = sdbWriteFileHead(pSdb, pFile); if (code != 0) { mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code)); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -507,7 +507,9 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { } } - taosCloseFile(&pFile); + if (taosCloseFile(&pFile) != 0) { + code = taosRenameFile(tmpfile, curfile); + } if (code == 0) { code = taosRenameFile(tmpfile, curfile); @@ -541,7 +543,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { return 0; } - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); if (pSdb->pWal != NULL) { if (pSdb->sync > 0) { code = syncBeginSnapshot(pSdb->sync, pSdb->applyIndex); @@ -560,7 +562,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { if (code != 0) { mError("failed to write sdb file since %s", tstrerror(code)); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -602,7 +604,7 @@ static void sdbCloseIter(SSdbIter *pIter) { if (pIter == NULL) return; if (pIter->file != NULL) { - taosCloseFile(&pIter->file); + (void)taosCloseFile(&pIter->file); pIter->file = NULL; } @@ -624,18 +626,18 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter char datafile[PATH_MAX] = {0}; snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP); - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); int64_t commitIndex = pSdb->commitIndex; int64_t commitTerm = pSdb->commitTerm; int64_t commitConfig = pSdb->commitConfig; if (taosCopyFile(datafile, pIter->name) < 0) { - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); code = TAOS_SYSTEM_ERROR(errno); mError("failed to copy sdb file %s to %s since %s", datafile, pIter->name, tstrerror(code)); sdbCloseIter(pIter); TAOS_RETURN(code); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); pIter->file = taosOpenFile(pIter->name, TD_FILE_READ); if (pIter->file == NULL) { @@ -725,7 +727,10 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i goto _OVER; } - taosCloseFile(&pIter->file); + if (taosCloseFile(&pIter->file) != 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _OVER; + } pIter->file = NULL; char datafile[PATH_MAX] = {0}; diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 4043ff6a12..03b45c25b4 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -176,7 +176,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * if (code != 0) { if (terrno == 0) terrno = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; code = terrno; - taosHashRemove(hash, pRow->pObj, keySize); + (void)taosHashRemove(hash, pRow->pObj, keySize); sdbFreeRow(pSdb, pRow, false); terrno = code; sdbUnLock(pSdb, type); @@ -239,10 +239,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * SSdbRow *pOldRow = *ppOldRow; pOldRow->status = pRaw->status; - atomic_add_fetch_32(&pOldRow->refCount, 1); + (void)atomic_add_fetch_32(&pOldRow->refCount, 1); sdbPrintOper(pSdb, pOldRow, "delete"); - taosHashRemove(hash, pOldRow->pObj, keySize); + TAOS_CHECK_RETURN(taosHashRemove(hash, pOldRow->pObj, keySize)); pSdb->tableVer[pOldRow->type]++; sdbUnLock(pSdb, type); @@ -309,7 +309,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) SSdbRow *pRow = *ppRow; switch (pRow->status) { case SDB_STATUS_READY: - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); break; @@ -327,7 +327,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) if (pRet == NULL) { if (!onlyReady) { terrno = 0; - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); } @@ -395,7 +395,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) { continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; break; @@ -423,7 +423,7 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; *status = pRow->status; diff --git a/source/dnode/mnode/sdb/src/sdbRow.c b/source/dnode/mnode/sdb/src/sdbRow.c index c078e7eb21..da5a232851 100644 --- a/source/dnode/mnode/sdb/src/sdbRow.c +++ b/source/dnode/mnode/sdb/src/sdbRow.c @@ -42,7 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) { // remove attached object such as trans SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; if (deleteFp != NULL) { - (*deleteFp)(pSdb, pRow->pObj, callFunc); + (void)(*deleteFp)(pSdb, pRow->pObj, callFunc); } sdbPrintOper(pSdb, pRow, "free"); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index da4763e56e..ce7c8aee7f 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -36,7 +36,7 @@ int32_t sndBuildStreamTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProce streamTaskOpenAllUpstreamInput(pTask); streamTaskResetUpstreamStageInfo(pTask); - (void) streamSetupScheduleTrigger(pTask); + (void)streamSetupScheduleTrigger(pTask); SCheckpointInfo *pChkInfo = &pTask->chkInfo; tqSetRestoreVersionInfo(pTask); @@ -91,14 +91,14 @@ FAIL: } int32_t sndInit(SSnode *pSnode) { - streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS); + (void)streamTaskSchedTask(&pSnode->msgCb, pSnode->pMeta->vgId, 0, 0, STREAM_EXEC_T_START_ALL_TASKS); return 0; } void sndClose(SSnode *pSnode) { stopRsync(); streamMetaNotifyClose(pSnode->pMeta); - streamMetaCommit(pSnode->pMeta); + (void)streamMetaCommit(pSnode->pMeta); streamMetaClose(pSnode->pMeta); taosMemoryFree(pSnode); } diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h index 29eaa0509a..243f51ca0a 100644 --- a/source/dnode/vnode/src/inc/sma.h +++ b/source/dnode/vnode/src/inc/sma.h @@ -194,7 +194,7 @@ typedef enum { #define TD_SMA_LOOPS_CHECK(n, limit) \ if (++(n) > limit) { \ - sched_yield(); \ + (void)sched_yield(); \ (n) = 0; \ } diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 978821f890..f6f86850a4 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -378,7 +378,7 @@ struct STsdb { struct { SVHashTable *ht; SArray *arr; - } *commitInfo; + } * commitInfo; }; struct TSDBKEY { @@ -937,7 +937,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb *pTsdb); int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, TSDBROW *row, bool dup); -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); +void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheGetBlockIdx(SLRUCache *pCache, SDataFReader *pFileReader, LRUHandle **handle); int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h); @@ -945,7 +945,6 @@ int32_t tsdbBICacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheGetBlockS3(SLRUCache *pCache, STsdbFD *pFD, LRUHandle **handle); int32_t tsdbCacheGetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, LRUHandle **handle); int32_t tsdbCacheSetPageS3(SLRUCache *pCache, STsdbFD *pFD, int64_t pgno, uint8_t *pPage); -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h); int32_t tsdbCacheDeleteLastrow(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); int32_t tsdbCacheDeleteLast(SLRUCache *pCache, tb_uid_t uid, TSKEY eKey); diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index 3d4757d3e4..8af902538d 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -530,12 +530,12 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK uint64_t key[4]; initCacheKey(key, pTableMap, suid, (const char*)pKey, keyLen); - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); pMeta->pCache->sTagFilterResCache.accTimes += 1; LRUHandle* pHandle = taosLRUCacheLookup(pCache, key, TAG_FILTER_RES_KEY_LEN); if (pHandle == NULL) { - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -565,7 +565,7 @@ int32_t metaGetCachedTableUidList(void* pVnode, tb_uid_t suid, const uint8_t* pK taosLRUCacheRelease(pCache, pHandle, false); // unlock meta - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -652,7 +652,7 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int uint64_t key[4] = {0}; initCacheKey(key, pTableEntry, suid, pKey, keyLen); - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t)); if (pEntry == NULL) { code = addNewEntry(pTableEntry, pKey, keyLen, suid); @@ -668,7 +668,7 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int uint64_t* p = (uint64_t*)pNode->data; if (p[1] == ((uint64_t*)pKey)[1] && p[0] == ((uint64_t*)pKey)[0]) { // we have already found the existed items, no need to added to cache anymore. - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } else { // not equal, append it tdListAppend(&(*pEntry)->list, pKey); @@ -680,7 +680,7 @@ int32_t metaUidFilterCachePut(void* pVnode, uint64_t suid, const void* pKey, int (void)taosLRUCacheInsert(pCache, key, TAG_FILTER_RES_KEY_LEN, pPayload, payloadLen, freeUidCachePayload, NULL, TAOS_LRU_PRIORITY_LOW, NULL); _end: - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", vgId, suid, (int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry)); @@ -697,11 +697,11 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) { initCacheKey(p, pEntryHashMap, suid, (char*)&dummy[0], 16); TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); STagFilterResEntry** pEntry = taosHashGet(pEntryHashMap, &suid, sizeof(uint64_t)); if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) { - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -717,7 +717,7 @@ int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) { } tdListEmpty(&(*pEntry)->list); - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); metaDebug("vgId:%d suid:%" PRId64 " cached related tag filter uid list cleared", vgId, suid); return TSDB_CODE_SUCCESS; @@ -736,12 +736,12 @@ int32_t metaGetCachedTbGroup(void* pVnode, tb_uid_t suid, const uint8_t* pKey, i uint64_t key[4]; initCacheKey(key, pTableMap, suid, (const char*)pKey, keyLen); - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); pMeta->pCache->STbGroupResCache.accTimes += 1; LRUHandle* pHandle = taosLRUCacheLookup(pCache, key, TAG_FILTER_RES_KEY_LEN); if (pHandle == NULL) { - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -764,7 +764,7 @@ int32_t metaGetCachedTbGroup(void* pVnode, tb_uid_t suid, const uint8_t* pKey, i taosLRUCacheRelease(pCache, pHandle, false); // unlock meta - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -829,7 +829,7 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int uint64_t key[4] = {0}; initCacheKey(key, pTableEntry, suid, pKey, keyLen); - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t)); if (pEntry == NULL) { code = addNewEntry(pTableEntry, pKey, keyLen, suid); @@ -845,7 +845,7 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int uint64_t* p = (uint64_t*)pNode->data; if (p[1] == ((uint64_t*)pKey)[1] && p[0] == ((uint64_t*)pKey)[0]) { // we have already found the existed items, no need to added to cache anymore. - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } else { // not equal, append it tdListAppend(&(*pEntry)->list, pKey); @@ -857,7 +857,7 @@ int32_t metaPutTbGroupToCache(void* pVnode, uint64_t suid, const void* pKey, int taosLRUCacheInsert(pCache, key, TAG_FILTER_RES_KEY_LEN, pPayload, payloadLen, freeTbGroupCachePayload, NULL, TAOS_LRU_PRIORITY_LOW, NULL); _end: - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); metaDebug("vgId:%d, suid:%" PRIu64 " tb group added into cache, total:%d, tables:%d", vgId, suid, (int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry)); @@ -874,11 +874,11 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) { initCacheKey(p, pEntryHashMap, suid, (char*)&dummy[0], 16); TdThreadMutex* pLock = &pMeta->pCache->STbGroupResCache.lock; - taosThreadMutexLock(pLock); + (void)taosThreadMutexLock(pLock); STagFilterResEntry** pEntry = taosHashGet(pEntryHashMap, &suid, sizeof(uint64_t)); if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) { - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } @@ -894,7 +894,7 @@ int32_t metaTbGroupCacheClear(SMeta* pMeta, uint64_t suid) { } tdListEmpty(&(*pEntry)->list); - taosThreadMutexUnlock(pLock); + (void)taosThreadMutexUnlock(pLock); metaDebug("vgId:%d suid:%" PRId64 " cached related tb group cleared", vgId, suid); return TSDB_CODE_SUCCESS; diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index e707f2150d..75b112f42b 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -257,7 +257,7 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) { if (RSMA_INFO_IS_DEL(pRSmaInfo)) { int32_t refVal = T_REF_VAL_GET(pRSmaInfo); if (refVal == 0) { - taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid)); + (void)taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid)); } else { smaDebug( "vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for " diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c index e7a8de17a0..a219da33db 100644 --- a/source/dnode/vnode/src/sma/smaEnv.c +++ b/source/dnode/vnode/src/sma/smaEnv.c @@ -46,7 +46,7 @@ int32_t smaInit() { old = atomic_val_compare_exchange_8(&smaMgmt.inited, 0, 2); if (old != 2) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -69,7 +69,7 @@ int32_t smaInit() { if (!smaMgmt.refHash || !smaMgmt.tmrHandle) { code = terrno; - taosCloseRef(smaMgmt.rsetId); + (void)taosCloseRef(smaMgmt.rsetId); if (smaMgmt.refHash) { taosHashCleanup(smaMgmt.refHash); smaMgmt.refHash = NULL; @@ -97,7 +97,7 @@ void smaCleanUp() { old = atomic_val_compare_exchange_8(&smaMgmt.inited, 1, 2); if (old != 2) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -130,7 +130,7 @@ static int32_t tdNewSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv) { : atomic_store_ptr(&SMA_RSMA_ENV(pSma), *ppEnv); if ((code = tdInitSmaStat(&SMA_ENV_STAT(pEnv), smaType, pSma)) != TSDB_CODE_SUCCESS) { - tdFreeSmaEnv(pEnv); + (void)tdFreeSmaEnv(pEnv); *ppEnv = NULL; (smaType == TSDB_SMA_TYPE_TIME_RANGE) ? atomic_store_ptr(&SMA_TSMA_ENV(pSma), NULL) : atomic_store_ptr(&SMA_RSMA_ENV(pSma), NULL); @@ -179,7 +179,7 @@ static void tRSmaInfoHashFreeNode(void *data) { if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 1)) && pItem->level) { (void)taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES); } - tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo); + (void)tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo); } } @@ -207,7 +207,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS SRSmaStat *pRSmaStat = (SRSmaStat *)(*pSmaStat); pRSmaStat->pSma = (SSma *)pSma; atomic_store_8(RSMA_TRIGGER_STAT(pRSmaStat), TASK_TRIGGER_STAT_INIT); - tsem_init(&pRSmaStat->notEmpty, 0, 0); + (void)tsem_init(&pRSmaStat->notEmpty, 0, 0); if (!(pRSmaStat->blocks = taosArrayInit(1, sizeof(SSDataBlock)))) { code = TSDB_CODE_OUT_OF_MEMORY; TAOS_CHECK_GOTO(code, &lino, _exit); @@ -216,7 +216,7 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS (void)taosArrayPush(pRSmaStat->blocks, &datablock); // init smaMgmt - smaInit(); + TAOS_CHECK_GOTO(smaInit(), &lino, _exit); int64_t refId = taosAddRef(smaMgmt.rsetId, pRSmaStat); if (refId < 0) { @@ -285,20 +285,20 @@ static void tdDestroyRSmaStat(void *pRSmaStat) { } // step 3: - tdRsmaStopExecutor(pSma); + (void)tdRsmaStopExecutor(pSma); // step 4: destroy the rsma info and associated fetch tasks taosHashCleanup(RSMA_INFO_HASH(pStat)); // step 5: free pStat - tsem_destroy(&(pStat->notEmpty)); + (void)tsem_destroy(&(pStat->notEmpty)); taosArrayDestroy(pStat->blocks); taosMemoryFreeClear(pStat); } } static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) { - tdDestroySmaState(pSmaStat, smaType); + (void)tdDestroySmaState(pSmaStat, smaType); if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { taosMemoryFreeClear(pSmaStat); } @@ -438,7 +438,7 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) { pthread = (TdThread *)&pStat->data; for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { - tsem_post(&(pRSmaStat->notEmpty)); + (void)tsem_post(&(pRSmaStat->notEmpty)); } for (int32_t i = 0; i < tsNumOfVnodeRsmaThreads; ++i) { diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index d5409cf268..ebff03ff99 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -412,7 +412,7 @@ int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con _exit: if (code != 0) { - tdFreeRSmaInfo(pSma, pRSmaInfo); + (void)tdFreeRSmaInfo(pSma, pRSmaInfo); } else { smaDebug("vgId:%d, register rsma info succeed for table %" PRIi64, SMA_VID(pSma), suid); } @@ -1264,7 +1264,7 @@ _checkpoint: if (pItem && pItem->pStreamTask) { SStreamTask *pTask = pItem->pStreamTask; // atomic_store_32(&pTask->pMeta->chkptNotReadyTasks, 1); - streamTaskSetActiveCheckpointInfo(pTask, checkpointId); + (void)streamTaskSetActiveCheckpointInfo(pTask, checkpointId); pTask->chkInfo.checkpointId = checkpointId; // 1pTask->checkpointingId; pTask->chkInfo.checkpointVer = pItem->submitReqVer; @@ -1373,7 +1373,7 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) { ", rsetId:%d refId:%" PRIi64, SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId); if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) { - taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); + (void)taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId); } tdReleaseRSmaInfo(pSma, pRSmaInfo); (void)tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId); @@ -1629,7 +1629,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { batchMax = TMAX(batchMax, 4); } while (occupied || (++batchCnt < batchMax)) { // greedy mode - taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock + (void)taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock int32_t qallItemSize = taosQallItemSize(pInfo->qall); if (qallItemSize > 0) { if ((code = tdRSmaBatchExec(pSma, pInfo, pInfo->qall, pSubmitArr, type)) != 0) { @@ -1663,7 +1663,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { } if (qallItemSize > 0) { - atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); + (void)atomic_fetch_sub_64(&pRSmaStat->nBufItems, qallItemSize); continue; } if (RSMA_NEED_FETCH(pInfo)) { @@ -1673,7 +1673,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) { break; } } - atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); + (void)atomic_val_compare_exchange_8(&pInfo->assigned, 1, 0); } } } else { diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 918fd9e5d3..96010728c2 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -123,7 +123,7 @@ static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t ver, const char *pMsg TAOS_CHECK_EXIT(metaCreateTSma(SMA_META(pSma), ver, pCfg)); // create stable to save tsma result in dstVgId - tNameFromString(&stbFullName, pCfg->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + (void)tNameFromString(&stbFullName, pCfg->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); pReq.name = (char *)tNameGetTableName(&stbFullName); pReq.suid = pCfg->dstTbUid; pReq.schemaRow = pCfg->schemaRow; @@ -283,7 +283,7 @@ static int32_t tsmaProcessDelReq(SSma *pSma, int64_t indexUid, SBatchDeleteReq * SEncoder encoder; tEncoderInit(&encoder, POINTER_SHIFT(pBuf, sizeof(SMsgHead)), len); - tEncodeSBatchDeleteReq(&encoder, pDelReq); + (void)tEncodeSBatchDeleteReq(&encoder, pDelReq); tEncoderClear(&encoder); ((SMsgHead *)pBuf)->vgId = TD_VID(pSma->pVnode); diff --git a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c index dda5173ad9..c7beee6e8a 100644 --- a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c @@ -39,13 +39,15 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa // alloc pReader = (SStreamTaskReader*)taosMemoryCalloc(1, sizeof(SStreamTaskReader)); if (pReader == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY); } pReader->pTq = pTq; pReader->sver = sver; pReader->ever = ever; pReader->tdbTbList = taosArrayInit(4, sizeof(STablePair)); + if (pReader->tdbTbList == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } STablePair pair1 = {.tbl = pTq->pStreamMeta->pTaskDb, .type = SNAP_DATA_STREAM_TASK}; taosArrayPush(pReader->tdbTbList, &pair1); @@ -60,16 +62,14 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa if (code) { tqInfo("vgId:%d, vnode stream-task snapshot reader failed to open, reason: %s", TD_VID(pTq->pVnode), tstrerror(code)); - taosMemoryFree(pReader); - goto _err; + TAOS_CHECK_GOTO(code, NULL, _err); } code = tdbTbcMoveToFirst(pReader->pCur); if (code) { tqInfo("vgId:%d, vnode stream-task snapshot reader failed to iterate, reason: %s", TD_VID(pTq->pVnode), tstrerror(code)); - taosMemoryFree(pReader); - goto _err; + TAOS_CHECK_GOTO(code, NULL, _err); } tqDebug("vgId:%d, vnode stream-task snapshot reader opened", TD_VID(pTq->pVnode)); @@ -79,11 +79,14 @@ int32_t streamTaskSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa _err: tqError("vgId:%d, vnode stream-task snapshot reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code)); + streamTaskSnapReaderClose(pReader); *ppReader = NULL; return code; } int32_t streamTaskSnapReaderClose(SStreamTaskReader* pReader) { + if (pReader == NULL) return 0; + int32_t code = 0; tqInfo("vgId:%d, vnode stream-task snapshot reader closed", TD_VID(pReader->pTq->pVnode)); taosArrayDestroy(pReader->tdbTbList); @@ -116,6 +119,10 @@ NextTbl: break; } else { pVal = taosMemoryCalloc(1, tLen); + if (pVal == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } memcpy(pVal, tVal, tLen); vLen = tLen; } @@ -174,8 +181,7 @@ int32_t streamTaskSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa // alloc pWriter = (SStreamTaskWriter*)taosMemoryCalloc(1, sizeof(*pWriter)); if (pWriter == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto _err; + TAOS_CHECK_RETURN(TSDB_CODE_OUT_OF_MEMORY); } pWriter->pTq = pTq; pWriter->sver = sver; @@ -184,12 +190,6 @@ int32_t streamTaskSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, SStreamTa *ppWriter = pWriter; tqDebug("vgId:%d, vnode stream-task snapshot writer opened", TD_VID(pTq->pVnode)); return code; - -_err: - tqError("vgId:%d, vnode stream-task snapshot writer failed to write since %s", TD_VID(pTq->pVnode), tstrerror(code)); - *ppWriter = NULL; - return code; - return 0; } int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) { @@ -207,8 +207,7 @@ int32_t streamTaskSnapWriterClose(SStreamTaskWriter* pWriter, int8_t rollback) { if (code) goto _err; } - if (tdbBegin(pTq->pStreamMeta->db, &pTq->pStreamMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { - code = -1; + if ((code = tdbBegin(pTq->pStreamMeta->db, &pTq->pStreamMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0)) < 0) { taosMemoryFree(pWriter); goto _err; } @@ -241,10 +240,11 @@ int32_t streamTaskSnapWrite(SStreamTaskWriter* pWriter, uint8_t* pData, uint32_t int64_t key[2] = {taskId.streamId, taskId.taskId}; streamMetaWLock(pTq->pStreamMeta); - if (tdbTbUpsert(pTq->pStreamMeta->pTaskDb, key, sizeof(int64_t) << 1, (uint8_t*)pData + sizeof(SSnapDataHdr), - nData - sizeof(SSnapDataHdr), pTq->pStreamMeta->txn) < 0) { + if ((code = + tdbTbUpsert(pTq->pStreamMeta->pTaskDb, key, sizeof(int64_t) << 1, (uint8_t*)pData + sizeof(SSnapDataHdr), + nData - sizeof(SSnapDataHdr), pTq->pStreamMeta->txn)) < 0) { streamMetaWUnLock(pTq->pStreamMeta); - return -1; + return code; } streamMetaWUnLock(pTq->pStreamMeta); } else if (pHdr->type == SNAP_DATA_STREAM_TASK_CHECKPOINT) { diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 7b785e0844..51de400305 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -117,7 +117,7 @@ typedef struct { static void tsdbGetRocksPath(STsdb *pTsdb, char *path) { SVnode *pVnode = pTsdb->pVnode; - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, path, TSDB_FILENAME_LEN); int32_t offset = strlen(path); snprintf(path + offset, TSDB_FILENAME_LEN - offset - 1, "%scache.rdb", TD_DIRSEP); @@ -722,20 +722,14 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[0], values_list_sizes[0], &pLastCol); if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[0], klen); } taosMemoryFreeClear(pLastCol); pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[1], values_list_sizes[1], &pLastCol); if (NULL != pLastCol) { rocksdb_writebatch_delete(wb, keys_list[1], klen); } @@ -748,7 +742,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, LRUHandle *h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[0], klen); if (h) { erase = true; - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[0], klen); @@ -758,7 +752,7 @@ static int32_t tsdbCacheDropTableColumn(STsdb *pTsdb, int64_t uid, int16_t cid, h = taosLRUCacheLookup(pTsdb->lruCache, keys_list[1], klen); if (h) { erase = true; - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[1], klen); @@ -1066,12 +1060,12 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray if (cmp_res < 0 || (cmp_res == 0 && !COL_VAL_IS_NONE(pColVal))) { tsdbCacheUpdateLastCol(pLastCol, pRowKey, pColVal); } - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); } else { if (!remainCols) { remainCols = taosArrayInit(num_keys * 2, sizeof(SIdxKey)); } - taosArrayPush(remainCols, &(SIdxKey){i, *key}); + (void)taosArrayPush(remainCols, &(SIdxKey){i, *key}); } } @@ -1123,10 +1117,12 @@ static int32_t tsdbCacheUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SArray SColVal *pColVal = &updCtx->colVal; SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); + /* if (code) { tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); } + */ SLastCol *PToFree = pLastCol; if (IS_LAST_KEY(idxKey->key) && !COL_VAL_IS_VALUE(pColVal)) { @@ -1242,18 +1238,18 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 tsdbRowGetKey(&lRow, &tsdbRowKey); STSDBRowIter iter = {0}; - tsdbRowIterOpen(&iter, &lRow, pTSchema); + (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); int32_t iCol = 0; for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal && iCol < nCol; pColVal = tsdbRowIterNext(&iter), iCol++) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); if (!COL_VAL_IS_VALUE(pColVal)) { - tSimpleHashPut(iColHash, &iCol, sizeof(iCol), NULL, 0); + (void)tSimpleHashPut(iColHash, &iCol, sizeof(iCol), NULL, 0); continue; } updateCtx.lflag = LFLAG_LAST; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } tsdbRowClose(&iter); @@ -1277,14 +1273,14 @@ int32_t tsdbCacheRowFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, int6 if (COL_VAL_IS_VALUE(&colVal)) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST, .tsdbRowKey = tsdbRowKey, .colVal = colVal}; - taosArrayPush(ctxArray, &updateCtx); - tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); + (void)taosArrayPush(ctxArray, &updateCtx); + (void)tSimpleHashIterateRemove(iColHash, &iCol, sizeof(iCol), &pIte, &iter); } } } // 3. do update - tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); _exit: taosMemoryFreeClear(pTSchema); @@ -1317,7 +1313,7 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo .tsdbRowKey = tsdbRowKey, .colVal = COL_VAL_VALUE(PRIMARYKEY_TIMESTAMP_COL_ID, ((SValue){.type = TSDB_DATA_TYPE_TIMESTAMP, .val = lRow.pBlockData->aTSKEY[lRow.iRow]}))}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } TSDBROW tRow = tsdbRowFromBlockData(pBlockData, 0); @@ -1338,7 +1334,7 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo tColDataGetValue(pColData, tRow.iRow, &colVal); SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST, .tsdbRowKey = tsdbRowKey, .colVal = colVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); break; } } @@ -1346,15 +1342,15 @@ int32_t tsdbCacheColFormatUpdate(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, SBlo // 2. prepare last row STSDBRowIter iter = {0}; - tsdbRowIterOpen(&iter, &lRow, pTSchema); + (void)tsdbRowIterOpen(&iter, &lRow, pTSchema); for (SColVal *pColVal = tsdbRowIterNext(&iter); pColVal; pColVal = tsdbRowIterNext(&iter)) { SLastUpdateCtx updateCtx = {.lflag = LFLAG_LAST_ROW, .tsdbRowKey = tsdbRowKey, .colVal = *pColVal}; - taosArrayPush(ctxArray, &updateCtx); + (void)taosArrayPush(ctxArray, &updateCtx); } tsdbRowClose(&iter); // 3. do update - tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); + (void)tsdbCacheUpdate(pTsdb, suid, uid, ctxArray); _exit: taosMemoryFreeClear(pTSchema); @@ -1379,7 +1375,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (idxKey->key.cid != PRIMARYKEY_TIMESTAMP_COL_ID) { SLastKey *key = &(SLastKey){.lflag = ltype, .uid = uid, .cid = PRIMARYKEY_TIMESTAMP_COL_ID}; - taosArrayInsert(remainCols, 0, &(SIdxKey){0, *key}); + (void)taosArrayInsert(remainCols, 0, &(SIdxKey){0, *key}); } int num_keys = TARRAY_SIZE(remainCols); @@ -1416,7 +1412,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (NULL == lastTmpIndexArray) { lastTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); } - taosArrayPush(lastTmpIndexArray, &(i)); + (void)taosArrayPush(lastTmpIndexArray, &(i)); lastColIds[lastIndex] = idxKey->key.cid; lastSlotIds[lastIndex] = pr->pSlotIds[idxKey->idx]; lastIndex++; @@ -1424,7 +1420,7 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr if (NULL == lastrowTmpIndexArray) { lastrowTmpIndexArray = taosArrayInit(num_keys, sizeof(int32_t)); } - taosArrayPush(lastrowTmpIndexArray, &(i)); + (void)taosArrayPush(lastrowTmpIndexArray, &(i)); lastrowColIds[lastrowIndex] = idxKey->key.cid; lastrowSlotIds[lastrowIndex] = pr->pSlotIds[idxKey->idx]; lastrowIndex++; @@ -1434,17 +1430,18 @@ static int32_t tsdbCacheLoadFromRaw(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArr pTmpColArray = taosArrayInit(lastIndex + lastrowIndex, sizeof(SLastCol)); if (lastTmpIndexArray != NULL) { - mergeLastCid(uid, pTsdb, &lastTmpColArray, pr, lastColIds, lastIndex, lastSlotIds); + (void)mergeLastCid(uid, pTsdb, &lastTmpColArray, pr, lastColIds, lastIndex, lastSlotIds); for (int i = 0; i < taosArrayGetSize(lastTmpColArray); i++) { - taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastTmpIndexArray, i), taosArrayGet(lastTmpColArray, i)); + (void)taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastTmpIndexArray, i), + taosArrayGet(lastTmpColArray, i)); } } if (lastrowTmpIndexArray != NULL) { - mergeLastRowCid(uid, pTsdb, &lastrowTmpColArray, pr, lastrowColIds, lastrowIndex, lastrowSlotIds); + (void)mergeLastRowCid(uid, pTsdb, &lastrowTmpColArray, pr, lastrowColIds, lastrowIndex, lastrowSlotIds); for (int i = 0; i < taosArrayGetSize(lastrowTmpColArray); i++) { - taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastrowTmpIndexArray, i), - taosArrayGet(lastrowTmpColArray, i)); + (void)taosArrayInsert(pTmpColArray, *(int32_t *)taosArrayGet(lastrowTmpIndexArray, i), + taosArrayGet(lastrowTmpColArray, i)); } } @@ -1586,10 +1583,7 @@ static int32_t tsdbCacheLoadFromRocks(STsdb *pTsdb, tb_uid_t uid, SArray *pLastA SLRUCache *pCache = pTsdb->lruCache; for (int i = 0, j = 0; i < num_keys && j < TARRAY_SIZE(remainCols); ++i) { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); SLastCol *PToFree = pLastCol; SIdxKey *idxKey = &((SIdxKey *)TARRAY_DATA(remainCols))[j]; if (pLastCol) { @@ -1682,19 +1676,19 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache TAOS_CHECK_RETURN(reallocVarDataVal(&lastCol.rowKey.pks[j])); } TAOS_CHECK_RETURN(reallocVarData(&lastCol.colVal)); - taosArrayPush(pLastArray, &lastCol); + (void)taosArrayPush(pLastArray, &lastCol); - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); } else { SLastCol noneCol = {.rowKey.ts = TSKEY_MIN, .colVal = COL_VAL_NONE(cid, pr->pSchema->columns[pr->pSlotIds[i]].type)}; - taosArrayPush(pLastArray, &noneCol); + (void)taosArrayPush(pLastArray, &noneCol); if (!remainCols) { remainCols = taosArrayInit(num_keys, sizeof(SIdxKey)); } - taosArrayPush(remainCols, &(SIdxKey){i, key}); + (void)taosArrayPush(remainCols, &(SIdxKey){i, key}); } } @@ -1721,7 +1715,7 @@ int32_t tsdbCacheGetBatch(STsdb *pTsdb, tb_uid_t uid, SArray *pLastArray, SCache } taosArraySet(pLastArray, idxKey->idx, &lastCol); - taosLRUCacheRelease(pCache, h, false); + (void)taosLRUCacheRelease(pCache, h, false); taosArrayRemove(remainCols, i); } else { @@ -1810,10 +1804,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE rocksdb_writebatch_t *wb = pTsdb->rCache.writebatch; for (int i = 0; i < num_keys; ++i) { SLastCol *pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i], values_list_sizes[i], &pLastCol); (void)taosThreadMutexLock(&pTsdb->rCache.rMutex); if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) { rocksdb_writebatch_delete(wb, keys_list[i], klen); @@ -1821,10 +1812,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE taosMemoryFreeClear(pLastCol); pLastCol = NULL; - code = tsdbCacheDeserialize(values_list[i + num_keys], values_list_sizes[i + num_keys], &pLastCol); - if (code) { - tsdbError("tsdb/cache: vgId:%d, deserialize failed since %s.", TD_VID(pTsdb->pVnode), tstrerror(code)); - } + (void)tsdbCacheDeserialize(values_list[i + num_keys], values_list_sizes[i + num_keys], &pLastCol); if (NULL != pLastCol && (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey)) { rocksdb_writebatch_delete(wb, keys_list[num_keys + i], klen); } @@ -1846,7 +1834,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE if (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey) { erase = true; } - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[i], klen); @@ -1862,7 +1850,7 @@ int32_t tsdbCacheDel(STsdb *pTsdb, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKE if (pLastCol->rowKey.ts <= eKey && pLastCol->rowKey.ts >= sKey) { erase = true; } - taosLRUCacheRelease(pTsdb->lruCache, h, erase); + (void)taosLRUCacheRelease(pTsdb->lruCache, h, erase); } if (erase) { taosLRUCacheErase(pTsdb->lruCache, keys_list[num_keys + i], klen); @@ -1982,7 +1970,7 @@ static int32_t getTableDelDataFromTbData(STbData *pTbData, SArray *aDelData) { SDelData *pDelData = pTbData ? pTbData->pHead : NULL; for (; pDelData; pDelData = pDelData->pNext) { - taosArrayPush(aDelData, pDelData); + (void)taosArrayPush(aDelData, pDelData); } return code; @@ -2005,7 +1993,7 @@ static STableLoadInfo *getTableLoadInfo(SCacheRowsReader *pReader, uint64_t uid) if (!ppInfo) { pInfo = taosMemoryCalloc(1, sizeof(STableLoadInfo)); if (pInfo) { - tSimpleHashPut(pReader->pTableMap, &uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); + (void)tSimpleHashPut(pReader->pTableMap, &uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); } return pInfo; @@ -2117,11 +2105,11 @@ static int32_t loadTombFromBlk(const TTombBlkArray *pTombBlkArray, SCacheRowsRea TD_VID(pReader->pTsdb->pVnode), pReader->pCurFileSet->fid, record.skey, record.ekey, uid);*/ SDelData delData = {.version = record.version, .sKey = record.skey, .eKey = record.ekey}; - taosArrayPush(pInfo->pTombData, &delData); + (void)taosArrayPush(pInfo->pTombData, &delData); } } - tTombBlockDestroy(&block); + (void)tTombBlockDestroy(&block); if (finished) { TAOS_RETURN(code); @@ -2312,7 +2300,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie state->pr->pCurFileSet = state->pFileSet; - loadDataTomb(state->pr, state->pr->pFileReader); + (void)loadDataTomb(state->pr, state->pr->pFileReader); TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlk(state->pr->pFileReader, &state->pr->pBlkArray), &lino, _err); } @@ -2329,7 +2317,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie SBrinBlk *pBrinBlk = &pBlkArray->data[i]; if (state->suid >= pBrinBlk->minTbid.suid && state->suid <= pBrinBlk->maxTbid.suid) { if (state->uid >= pBrinBlk->minTbid.uid && state->uid <= pBrinBlk->maxTbid.uid) { - taosArrayPush(state->pIndexList, pBrinBlk); + (void)taosArrayPush(state->pIndexList, pBrinBlk); } } else if (state->suid > pBrinBlk->maxTbid.suid || (state->suid == pBrinBlk->maxTbid.suid && state->uid > pBrinBlk->maxTbid.uid)) { @@ -2385,7 +2373,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } clearLastFileSet(state); @@ -2419,7 +2407,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pBrinBlock) { state->pBrinBlock = &state->brinBlock; } else { - tBrinBlockClear(&state->brinBlock); + (void)tBrinBlockClear(&state->brinBlock); } TAOS_CHECK_GOTO(tsdbDataFileReadBrinBlock(state->pr->pFileReader, pBrinBlk, &state->brinBlock), &lino, _err); @@ -2431,7 +2419,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (SFSNEXTROW_BRINBLOCK == state->state) { _next_brinrecord: if (state->iBrinRecord < 0) { // empty brin block, goto _next_brinindex - tBrinBlockClear(&state->brinBlock); + (void)tBrinBlockClear(&state->brinBlock); goto _next_brinindex; } @@ -2493,7 +2481,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie if (!state->pLastRow) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } *ppRow = &state->row; @@ -2517,7 +2505,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie } else { // TODO: merge rows and *ppRow = mergedRow SRowMerger *pMerger = &state->rowMerger; - tsdbRowMergerInit(pMerger, state->pTSchema); + (void)tsdbRowMergerInit(pMerger, state->pTSchema); TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, &state->row, state->pTSchema), &lino, _err); TAOS_CHECK_GOTO(tsdbRowMergerAdd(pMerger, state->pLastRow, state->pTSchema), &lino, _err); @@ -2682,7 +2670,7 @@ int32_t clearNextRowFromFS(void *iter) { } if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } if (state->pBlockData) { @@ -2691,7 +2679,7 @@ int32_t clearNextRowFromFS(void *iter) { } if (state->pBrinBlock) { - tBrinBlockDestroy(state->pBrinBlock); + (void)tBrinBlockDestroy(state->pBrinBlock); state->pBrinBlock = NULL; } @@ -2715,7 +2703,7 @@ int32_t clearNextRowFromFS(void *iter) { static void clearLastFileSet(SFSNextRowIter *state) { if (state->pLastIter) { - lastIterClose(&state->pLastIter); + (void)lastIterClose(&state->pLastIter); } if (state->pBlockData) { @@ -2724,7 +2712,7 @@ static void clearLastFileSet(SFSNextRowIter *state) { } if (state->pr->pFileReader) { - tsdbDataFileReaderClose(&state->pr->pFileReader); + (void)tsdbDataFileReaderClose(&state->pr->pFileReader); state->pr->pFileReader = NULL; state->pr->pCurFileSet = NULL; @@ -2814,7 +2802,7 @@ static int32_t nextRowIterClose(CacheNextRowIter *pIter) { for (int i = 0; i < 3; ++i) { if (pIter->input[i].nextRowClearFn) { - pIter->input[i].nextRowClearFn(pIter->input[i].iter); + (void)pIter->input[i].nextRowClearFn(pIter->input[i].iter); } } @@ -2898,7 +2886,7 @@ static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pI pInfo->pTombData = taosArrayInit(4, sizeof(SDelData)); } - taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData); + (void)taosArrayAddAll(pInfo->pTombData, pIter->pMemDelData); size_t delSize = TARRAY_SIZE(pInfo->pTombData); if (delSize > 0) { @@ -2944,7 +2932,7 @@ static int32_t initLastColArrayPartial(STSchema *pTSchema, SArray **ppColArray, int16_t slotId = slotIds[i]; SLastCol col = {.rowKey.ts = 0, .colVal = COL_VAL_NULL(pTSchema->columns[slotId].colId, pTSchema->columns[slotId].type)}; - taosArrayPush(pColArray, &col); + (void)taosArrayPush(pColArray, &col); } *ppColArray = pColArray; @@ -2998,18 +2986,18 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC } for (int i = 0; i < nCols; ++i) { - taosArrayPush(aColArray, &aCols[i]); + (void)taosArrayPush(aColArray, &aCols[i]); } STsdbRowKey lastRowKey = {.key.ts = TSKEY_MAX}; // inverse iterator CacheNextRowIter iter = {0}; - nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); + (void)nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, true, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); + (void)nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, true, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); if (!pRow) { break; @@ -3142,7 +3130,7 @@ static int32_t mergeLastCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SC } *ppLastArray = pColArray; - nextRowIterClose(&iter); + (void)nextRowIterClose(&iter); taosArrayDestroy(aColArray); TAOS_RETURN(code); @@ -3184,16 +3172,16 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, } for (int i = 0; i < nCols; ++i) { - taosArrayPush(aColArray, &aCols[i]); + (void)taosArrayPush(aColArray, &aCols[i]); } // inverse iterator CacheNextRowIter iter = {0}; - nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); + (void)nextRowIterOpen(&iter, uid, pTsdb, pTSchema, pr->info.suid, pr->pLDataIterArray, pr->pReadSnap, pr->lastTs, pr); do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, false, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); + (void)nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, false, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); if (!pRow) { break; @@ -3266,7 +3254,7 @@ static int32_t mergeLastRowCid(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, } *ppLastArray = pColArray; - nextRowIterClose(&iter); + (void)nextRowIterClose(&iter); taosArrayDestroy(aColArray); TAOS_RETURN(code); @@ -3286,13 +3274,7 @@ _err: TAOS_RETURN(code); } -int32_t tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { - int32_t code = 0; - - taosLRUCacheRelease(pCache, h, false); - - return code; -} +void tsdbCacheRelease(SLRUCache *pCache, LRUHandle *h) { taosLRUCacheRelease(pCache, h, false); } void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) { taosLRUCacheSetCapacity(pVnode->pTsdb->lruCache, capacity); diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 728db63cab..0c3fc95d6c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -540,7 +540,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { } } - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); // scan tomb data if (tsdb->imem->nDel > 0) { @@ -572,7 +572,7 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { } else { hasDataToCommit = true; if ((code = tsdbCommitInfoAdd(tsdb, fset->fid))) { - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } break; @@ -593,13 +593,13 @@ static int32_t tsdbCommitInfoBuild(STsdb *tsdb) { if (fset) { code = tsdbTFileSetInitCopy(tsdb, fset, &info->fset); if (code) { - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); TAOS_CHECK_GOTO(code, &lino, _exit); } } } - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); _exit: if (code) { @@ -667,11 +667,11 @@ _exit: } int32_t tsdbPreCommit(STsdb *tsdb) { - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); ASSERT_CORE(tsdb->imem == NULL, "imem should be null to commit mem"); tsdb->imem = tsdb->mem; tsdb->mem = NULL; - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); return 0; } @@ -686,9 +686,9 @@ int32_t tsdbCommitBegin(STsdb *tsdb, SCommitInfo *info) { int64_t nDel = imem->nDel; if (nRow == 0 && nDel == 0) { - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); tsdb->imem = NULL; - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); tsdbUnrefMemTable(imem, NULL, true); } else { SCommitter2 committer = {0}; @@ -719,10 +719,10 @@ int32_t tsdbCommitCommit(STsdb *tsdb) { if (tsdb->imem) { SMemTable *pMemTable = tsdb->imem; - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); if ((code = tsdbFSEditCommit(tsdb->pFS))) { - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } tsdb->imem = NULL; @@ -734,7 +734,7 @@ int32_t tsdbCommitCommit(STsdb *tsdb) { } } - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); tsdbCommitInfoDestroy(tsdb); tsdbUnrefMemTable(pMemTable, NULL, true); @@ -757,14 +757,14 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) { TAOS_CHECK_GOTO(tsdbFSEditAbort(pTsdb->pFS), &lino, _exit); - taosThreadMutexLock(&pTsdb->mutex); + (void)taosThreadMutexLock(&pTsdb->mutex); for (int32_t i = 0; i < taosArrayGetSize(pTsdb->commitInfo->arr); i++) { SFileSetCommitInfo *info = *(SFileSetCommitInfo **)taosArrayGet(pTsdb->commitInfo->arr, i); if (info->fset) { tsdbFinishTaskOnFileSet(pTsdb, info->fid); } } - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); tsdbCommitInfoDestroy(pTsdb); _exit: diff --git a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c index 72379449fc..28598f23f7 100644 --- a/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbDataFileRW.c @@ -230,7 +230,7 @@ int32_t tsdbDataFileReadBrinBlock(SDataFileReader *reader, const SBrinBlk *brinB // decode brin block SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer); - tBrinBlockClear(brinBlock); + (void)tBrinBlockClear(brinBlock); brinBlock->numOfPKs = brinBlk->numOfPKs; brinBlock->numOfRecords = brinBlk->numRec; for (int32_t i = 0; i < 10; i++) { // int64_t @@ -673,12 +673,12 @@ static int32_t tsdbDataFileWriterDoClose(SDataFileWriter *writer) { tTombBlockDestroy(writer->tombBlock); TARRAY2_DESTROY(writer->tombBlkArray, NULL); tBlockDataDestroy(writer->blockData); - tBrinBlockDestroy(writer->brinBlock); + (void)tBrinBlockDestroy(writer->brinBlock); TARRAY2_DESTROY(writer->brinBlkArray, NULL); tTombBlockDestroy(writer->ctx->tombBlock); tBlockDataDestroy(writer->ctx->blockData); - tBrinBlockDestroy(writer->ctx->brinBlock); + (void)tBrinBlockDestroy(writer->ctx->brinBlock); for (int32_t i = 0; i < ARRAY_SIZE(writer->local); ++i) { tBufferDestroy(writer->local + i); @@ -838,7 +838,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr for (int i = 0; i < brinBlock->numOfRecords; i++) { SBrinRecord record; - tBrinBlockGet(brinBlock, i, &record); + (void)tBrinBlockGet(brinBlock, i, &record); if (i == 0) { brinBlk.minTbid.suid = record.suid; brinBlk.minTbid.uid = record.uid; @@ -918,7 +918,7 @@ int32_t tsdbFileWriteBrinBlock(STsdbFD *fd, SBrinBlock *brinBlock, uint32_t cmpr // append to brinBlkArray TAOS_CHECK_RETURN(TARRAY2_APPEND_PTR(brinBlkArray, &brinBlk)); - tBrinBlockClear(brinBlock); + (void)tBrinBlockClear(brinBlock); return 0; } @@ -1147,7 +1147,7 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST for (; writer->ctx->brinBlockIdx < writer->ctx->brinBlock->numOfRecords; writer->ctx->brinBlockIdx++) { SBrinRecord record; - tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); + (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, &record); if (record.uid != writer->ctx->tbid->uid) { writer->ctx->tbHasOldData = false; goto _exit; @@ -1157,7 +1157,7 @@ static int32_t tsdbDataFileDoWriteTableOldData(SDataFileWriter *writer, const ST goto _exit; } else { SBrinRecord record[1]; - tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); + (void)tBrinBlockGet(writer->ctx->brinBlock, writer->ctx->brinBlockIdx, record); if (tsdbRowKeyCmprNullAsLargest(key, &record->lastKey) > 0) { // key > record->lastKey if (writer->blockData->nRow > 0) { TAOS_CHECK_GOTO(tsdbDataFileDoWriteBlockData(writer, writer->blockData), &lino, _exit); @@ -1351,7 +1351,7 @@ int32_t tsdbFileWriteTombBlock(STsdbFD *fd, STombBlock *tombBlock, int8_t cmprAl }; for (int i = 0; i < TOMB_BLOCK_SIZE(tombBlock); i++) { STombRecord record; - tTombBlockGet(tombBlock, i, &record); + TAOS_UNUSED(tTombBlockGet(tombBlock, i, &record)); if (i == 0) { tombBlk.minTbid.suid = record.suid; @@ -1506,7 +1506,7 @@ static int32_t tsdbDataFileDoWriteTombRecord(SDataFileWriter *writer, const STom while (writer->ctx->hasOldTomb) { for (; writer->ctx->tombBlockIdx < TOMB_BLOCK_SIZE(writer->ctx->tombBlock); writer->ctx->tombBlockIdx++) { STombRecord record1[1]; - tTombBlockGet(writer->ctx->tombBlock, writer->ctx->tombBlockIdx, record1); + TAOS_UNUSED(tTombBlockGet(writer->ctx->tombBlock, writer->ctx->tombBlockIdx, record1)); int32_t c = tTombRecordCompare(record, record1); if (c < 0) { diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index b262912f9b..cc89b106da 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -102,8 +102,8 @@ static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); } - tsdbFSToBinary(pData, pFS); - taosCalcChecksumAppend(0, pData, size); + (void)tsdbFSToBinary(pData, pFS); + (void)taosCalcChecksumAppend(0, pData, size); // save to file pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC | TD_FILE_WRITE_THROUGH); @@ -125,7 +125,7 @@ _exit: tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); } taosMemoryFree(pData); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); return code; } @@ -267,14 +267,14 @@ void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) { // CURRENT if (current) { - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current, TSDB_FILENAME_LEN); offset = strlen(current); snprintf(current + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT", TD_DIRSEP); } // CURRENT.t if (current_t) { - vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pTsdb->path, pVnode->diskPrimary, pVnode->pTfs, current_t, TSDB_FILENAME_LEN); offset = strlen(current_t); snprintf(current_t + offset, TSDB_FILENAME_LEN - offset - 1, "%sCURRENT.t", TD_DIRSEP); } @@ -295,26 +295,26 @@ static int32_t load_fs(const char *fname, STsdbFS *pFS) { int64_t size; if (taosFStatFile(pFD, &size, NULL) < 0) { code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } pData = taosMemoryMalloc(size); if (pData == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } if (taosReadFile(pFD, pData, size) < 0) { code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } if (!taosCheckChecksumWhole(pData, size)) { code = TSDB_CODE_FILE_CORRUPTED; - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); TSDB_CHECK_CODE(code, lino, _exit); } @@ -326,7 +326,7 @@ _exit: tsdbError("%s failed at line %d since %s, fname:%s", __func__, lino, tstrerror(code), fname); } taosMemoryFree(pData); - taosCloseFile(&pFD); + (void)taosCloseFile(&pFD); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbFS2.c b/source/dnode/vnode/src/tsdb/tsdbFS2.c index 3b0a40c475..ff97274097 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS2.c @@ -761,7 +761,7 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { return TSDB_CODE_OUT_OF_MEMORY; } - taosThreadMutexLock(&pTsdb->mutex); + (void)taosThreadMutexLock(&pTsdb->mutex); // disable pTsdb->bgTaskDisabled = true; @@ -772,7 +772,7 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { if (fset->channelOpened) { if (taosArrayPush(channelArray, &fset->channel) == NULL) { taosArrayDestroy(channelArray); - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); return terrno; } fset->channel = (SVAChannelID){0}; @@ -782,7 +782,7 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { } } - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); // destroy all channels for (int32_t i = 0; i < taosArrayGetSize(channelArray); i++) { @@ -798,9 +798,9 @@ int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb) { } int32_t tsdbEnableBgTask(STsdb *pTsdb) { - taosThreadMutexLock(&pTsdb->mutex); + (void)taosThreadMutexLock(&pTsdb->mutex); pTsdb->bgTaskDisabled = false; - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); return 0; } @@ -814,16 +814,16 @@ int32_t tsdbCloseFS(STFileSystem **fs) { } int64_t tsdbFSAllocEid(STFileSystem *fs) { - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); int64_t cid = ++fs->neid; - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); return cid; } void tsdbFSUpdateEid(STFileSystem *fs, int64_t cid) { - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); fs->neid = TMAX(fs->neid, cid); - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); } int32_t tsdbFSEditBegin(STFileSystem *fs, const TFileOpArray *opArray, EFEditT etype) { @@ -871,7 +871,7 @@ static int32_t tsdbFSSetBlockCommit(STFileSet *fset, bool block) { } int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) { - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); STFileSet *fset; tsdbFSGetFSet(tsdb->pFS, fid, &fset); if (fset) { @@ -881,7 +881,7 @@ int32_t tsdbFSCheckCommit(STsdb *tsdb, int32_t fid) { fset->numWaitCommit--; } } - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); return 0; } @@ -973,7 +973,7 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { TARRAY2_INIT(fsetArr[0]); - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { code = tsdbTFileSetInitCopy(fs->tsdb, fset, &fset1); if (code) break; @@ -981,7 +981,7 @@ int32_t tsdbFSCreateCopySnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { code = TARRAY2_APPEND(fsetArr[0], fset1); if (code) break; } - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { TARRAY2_DESTROY(fsetArr[0], tsdbTFileSetClear); @@ -1001,9 +1001,9 @@ int32_t tsdbFSDestroyCopySnapshot(TFileSetArray **fsetArr) { } int32_t tsdbFSCreateRefSnapshot(STFileSystem *fs, TFileSetArray **fsetArr) { - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); int32_t code = tsdbFSCreateRefSnapshotWithoutLock(fs, fsetArr); - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); return code; } @@ -1075,7 +1075,7 @@ int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pRa } } - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { int64_t ever = VERSION_MAX; if (pHash) { @@ -1092,7 +1092,7 @@ int32_t tsdbFSCreateCopyRangedSnapshot(STFileSystem *fs, TFileSetRangeArray *pRa code = TARRAY2_APPEND(fsetArr[0], fset1); if (code) break; } - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); _out: if (code) { @@ -1131,7 +1131,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev } } - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); TARRAY2_FOREACH(fs->fSetArr, fset) { int64_t sver1 = sver; int64_t ever1 = ever; @@ -1160,7 +1160,7 @@ int32_t tsdbFSCreateRefRangedSnapshot(STFileSystem *fs, int64_t sver, int64_t ev fsr1 = NULL; } - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { tsdbTFileSetRangeClear(&fsr1); diff --git a/source/dnode/vnode/src/tsdb/tsdbFSet2.c b/source/dnode/vnode/src/tsdb/tsdbFSet2.c index 305ce6b56f..5ad7807f02 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFSet2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFSet2.c @@ -61,7 +61,7 @@ static int32_t tsdbSttLvlInitRef(STsdb *pTsdb, const SSttLvl *lvl1, SSttLvl **lv STFileObj *fobj1; TARRAY2_FOREACH(lvl1->fobjArr, fobj1) { - tsdbTFileObjRef(fobj1); + (void)tsdbTFileObjRef(fobj1); code = TARRAY2_APPEND(lvl[0]->fobjArr, fobj1); if (code) return code; } @@ -96,7 +96,7 @@ static int32_t tsdbSttLvlFilteredInitEx(STsdb *pTsdb, const SSttLvl *lvl1, int64 return 0; } -static void tsdbSttLvlRemoveFObj(void *data) { tsdbTFileObjRemove(*(STFileObj **)data); } +static void tsdbSttLvlRemoveFObj(void *data) { (void)tsdbTFileObjRemove(*(STFileObj **)data); } static void tsdbSttLvlRemove(SSttLvl **lvl) { TARRAY2_DESTROY(lvl[0]->fobjArr, tsdbSttLvlRemoveFObj); taosMemoryFree(lvl[0]); @@ -173,7 +173,7 @@ static int32_t tsdbSttLvlToJson(const SSttLvl *lvl, cJSON *json) { TARRAY2_FOREACH(lvl->fobjArr, fobj) { cJSON *item = cJSON_CreateObject(); if (item == NULL) return TSDB_CODE_OUT_OF_MEMORY; - cJSON_AddItemToArray(ajson, item); + (void)cJSON_AddItemToArray(ajson, item); int32_t code = tsdbTFileToJson(fobj->f, item); if (code) return code; @@ -198,7 +198,7 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl) item1 = cJSON_GetObjectItem(json, "files"); if (!cJSON_IsArray(item1)) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return TSDB_CODE_FILE_CORRUPTED; } @@ -206,14 +206,14 @@ static int32_t tsdbJsonToSttLvl(STsdb *pTsdb, const cJSON *json, SSttLvl **lvl) STFile tf; code = tsdbJsonToTFile(item2, TSDB_FTYPE_STT, &tf); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } STFileObj *fobj; code = tsdbTFileObjInit(pTsdb, &tf, &fobj); if (code) { - tsdbSttLvlClear(lvl); + (void)tsdbSttLvlClear(lvl); return code; } @@ -247,7 +247,7 @@ int32_t tsdbTFileSetToJson(const STFileSet *fset, cJSON *json) { TARRAY2_FOREACH(fset->lvlArr, lvl) { item2 = cJSON_CreateObject(); if (!item2) return TSDB_CODE_OUT_OF_MEMORY; - cJSON_AddItemToArray(item1, item2); + (void)cJSON_AddItemToArray(item1, item2); code = tsdbSttLvlToJson(lvl, item2); if (code) return code; @@ -347,7 +347,7 @@ int32_t tsdbTFileSetEdit(STsdb *pTsdb, STFileSet *fset, const STFileOp *op) { TARRAY2_REMOVE(lvl->fobjArr, idx, tsdbSttLvlClearFObj); } else { ASSERT(tsdbIsSameTFile(&op->of, fset->farr[op->of.type]->f)); - tsdbTFileObjUnref(fset->farr[op->of.type]); + (void)tsdbTFileObjUnref(fset->farr[op->of.type]); fset->farr[op->of.type] = NULL; } } else { @@ -389,9 +389,9 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f } } else { if (fobj1->f->cid != fobj2->f->cid) { - tsdbTFileObjRemove(fobj2); + (void)tsdbTFileObjRemove(fobj2); } else { - tsdbTFileObjRemoveUpdateLC(fobj2); + (void)tsdbTFileObjRemoveUpdateLC(fobj2); } code = tsdbTFileObjInit(pTsdb, fobj1->f, &fset2->farr[ftype]); if (code) return code; @@ -402,7 +402,7 @@ int32_t tsdbTFileSetApplyEdit(STsdb *pTsdb, const STFileSet *fset1, STFileSet *f if (code) return code; } else { // remove the file - tsdbTFileObjRemove(fobj2); + (void)tsdbTFileObjRemove(fobj2); fset2->farr[ftype] = NULL; } } @@ -460,12 +460,12 @@ int32_t tsdbTFileSetInit(int32_t fid, STFileSet **fset) { TARRAY2_INIT(fset[0]->lvlArr); // background task queue - taosThreadCondInit(&(*fset)->beginTask, NULL); + (void)taosThreadCondInit(&(*fset)->beginTask, NULL); (*fset)->taskRunning = false; (*fset)->numWaitTask = 0; // block commit variables - taosThreadCondInit(&fset[0]->canCommit, NULL); + (void)taosThreadCondInit(&fset[0]->canCommit, NULL); (*fset)->numWaitCommit = 0; (*fset)->blockCommit = false; @@ -567,7 +567,7 @@ int32_t tsdbTFileSetInitRef(STsdb *pTsdb, const STFileSet *fset1, STFileSet **fs for (int32_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset1->farr[ftype] == NULL) continue; - tsdbTFileObjRef(fset1->farr[ftype]); + (void)tsdbTFileObjRef(fset1->farr[ftype]); fset[0]->farr[ftype] = fset1->farr[ftype]; } @@ -609,13 +609,13 @@ void tsdbTFileSetClear(STFileSet **fset) { if (fset && *fset) { for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if ((*fset)->farr[ftype] == NULL) continue; - tsdbTFileObjUnref((*fset)->farr[ftype]); + (void)tsdbTFileObjUnref((*fset)->farr[ftype]); } TARRAY2_DESTROY((*fset)->lvlArr, tsdbSttLvlClear); - taosThreadCondDestroy(&(*fset)->beginTask); - taosThreadCondDestroy(&(*fset)->canCommit); + (void)taosThreadCondDestroy(&(*fset)->beginTask); + (void)taosThreadCondDestroy(&(*fset)->canCommit); taosMemoryFreeClear(*fset); } } @@ -625,7 +625,7 @@ int32_t tsdbTFileSetRemove(STFileSet *fset) { for (tsdb_ftype_t ftype = TSDB_FTYPE_MIN; ftype < TSDB_FTYPE_MAX; ++ftype) { if (fset->farr[ftype] != NULL) { - tsdbTFileObjRemove(fset->farr[ftype]); + (void)tsdbTFileObjRemove(fset->farr[ftype]); fset->farr[ftype] = NULL; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbFile2.c b/source/dnode/vnode/src/tsdb/tsdbFile2.c index 52f1ef72ee..3d6a259254 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile2.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile2.c @@ -230,11 +230,11 @@ int32_t tsdbTFileObjInit(STsdb *pTsdb, const STFile *f, STFileObj **fobj) { return terrno; } - taosThreadMutexInit(&fobj[0]->mutex, NULL); + (void)taosThreadMutexInit(&fobj[0]->mutex, NULL); fobj[0]->f[0] = f[0]; fobj[0]->state = TSDB_FSTATE_LIVE; fobj[0]->ref = 1; - tsdbTFileName(pTsdb, f, fobj[0]->fname); + (void)tsdbTFileName(pTsdb, f, fobj[0]->fname); // fobj[0]->nlevel = tfsGetLevel(pTsdb->pVnode->pTfs); fobj[0]->nlevel = vnodeNodeId(pTsdb->pVnode); return 0; @@ -242,18 +242,18 @@ int32_t tsdbTFileObjInit(STsdb *pTsdb, const STFile *f, STFileObj **fobj) { int32_t tsdbTFileObjRef(STFileObj *fobj) { int32_t nRef; - taosThreadMutexLock(&fobj->mutex); + (void)(void)taosThreadMutexLock(&fobj->mutex); ASSERT(fobj->ref > 0 && fobj->state == TSDB_FSTATE_LIVE); nRef = ++fobj->ref; - taosThreadMutexUnlock(&fobj->mutex); + (void)(void)taosThreadMutexUnlock(&fobj->mutex); tsdbTrace("ref file %s, fobj:%p ref %d", fobj->fname, fobj, nRef); return 0; } int32_t tsdbTFileObjUnref(STFileObj *fobj) { - taosThreadMutexLock(&fobj->mutex); + (void)(void)taosThreadMutexLock(&fobj->mutex); int32_t nRef = --fobj->ref; - taosThreadMutexUnlock(&fobj->mutex); + (void)(void)taosThreadMutexUnlock(&fobj->mutex); ASSERT(nRef >= 0); tsdbTrace("unref file %s, fobj:%p ref %d", fobj->fname, fobj, nRef); if (nRef == 0) { @@ -318,11 +318,11 @@ static void tsdbTFileObjRemoveLC(STFileObj *fobj, bool remove_all) { } int32_t tsdbTFileObjRemove(STFileObj *fobj) { - taosThreadMutexLock(&fobj->mutex); + (void)taosThreadMutexLock(&fobj->mutex); ASSERT(fobj->state == TSDB_FSTATE_LIVE && fobj->ref > 0); fobj->state = TSDB_FSTATE_DEAD; int32_t nRef = --fobj->ref; - taosThreadMutexUnlock(&fobj->mutex); + (void)taosThreadMutexUnlock(&fobj->mutex); tsdbTrace("remove unref file %s, fobj:%p ref %d", fobj->fname, fobj, nRef); if (nRef == 0) { tsdbTFileObjRemoveLC(fobj, true); @@ -332,11 +332,11 @@ int32_t tsdbTFileObjRemove(STFileObj *fobj) { } int32_t tsdbTFileObjRemoveUpdateLC(STFileObj *fobj) { - taosThreadMutexLock(&fobj->mutex); + (void)taosThreadMutexLock(&fobj->mutex); ASSERT(fobj->state == TSDB_FSTATE_LIVE && fobj->ref > 0); fobj->state = TSDB_FSTATE_DEAD; int32_t nRef = --fobj->ref; - taosThreadMutexUnlock(&fobj->mutex); + (void)taosThreadMutexUnlock(&fobj->mutex); tsdbTrace("remove unref file %s, fobj:%p ref %d", fobj->fname, fobj, nRef); if (nRef == 0) { tsdbTFileObjRemoveLC(fobj, false); diff --git a/source/dnode/vnode/src/tsdb/tsdbIter.c b/source/dnode/vnode/src/tsdb/tsdbIter.c index d97a5153f3..3b5bd6d02f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbIter.c +++ b/source/dnode/vnode/src/tsdb/tsdbIter.c @@ -153,7 +153,7 @@ static int32_t tsdbDataIterNext(STsdbIter *iter, const TABLEID *tbid) { for (; iter->dataData->brinBlockIdx < iter->dataData->brinBlock->numOfRecords; iter->dataData->brinBlockIdx++) { SBrinRecord record[1]; - tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); + (void)tBrinBlockGet(iter->dataData->brinBlock, iter->dataData->brinBlockIdx, record); if (iter->filterByVersion && (record->maxVer < iter->range[0] || record->minVer > iter->range[1])) { continue; @@ -254,7 +254,8 @@ _exit: static int32_t tsdbDataTombIterNext(STsdbIter *iter, const TABLEID *tbid) { while (!iter->noMoreData) { for (; iter->dataTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->dataTomb->tombBlock); iter->dataTomb->tombBlockIdx++) { - tTombBlockGet(iter->dataTomb->tombBlock, iter->dataTomb->tombBlockIdx, iter->record); + int32_t code = tTombBlockGet(iter->dataTomb->tombBlock, iter->dataTomb->tombBlockIdx, iter->record); + if (code) return code; if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { continue; @@ -372,7 +373,7 @@ static int32_t tsdbDataIterOpen(STsdbIter *iter) { iter->dataData->brinBlkArrayIdx = 0; // SBrinBlock - tBrinBlockInit(iter->dataData->brinBlock); + (void)tBrinBlockInit(iter->dataData->brinBlock); iter->dataData->brinBlockIdx = 0; // SBlockData @@ -429,7 +430,7 @@ static int32_t tsdbMemTombIterOpen(STsdbIter *iter) { } static int32_t tsdbDataIterClose(STsdbIter *iter) { - tBrinBlockDestroy(iter->dataData->brinBlock); + (void)tBrinBlockDestroy(iter->dataData->brinBlock); tBlockDataDestroy(iter->dataData->blockData); return 0; } @@ -439,7 +440,8 @@ static int32_t tsdbMemTableIterClose(STsdbIter *iter) { return 0; } static int32_t tsdbSttTombIterNext(STsdbIter *iter, const TABLEID *tbid) { while (!iter->noMoreData) { for (; iter->sttTomb->tombBlockIdx < TOMB_BLOCK_SIZE(iter->sttTomb->tombBlock); iter->sttTomb->tombBlockIdx++) { - tTombBlockGet(iter->sttTomb->tombBlock, iter->sttTomb->tombBlockIdx, iter->record); + int32_t code = tTombBlockGet(iter->sttTomb->tombBlock, iter->sttTomb->tombBlockIdx, iter->record); + if (code) return code; if (iter->filterByVersion && (iter->record->version < iter->range[0] || iter->record->version > iter->range[1])) { continue; diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index 3114c0fa04..d8ec014985 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -410,7 +410,7 @@ static int32_t tsdbGetOrCreateTbData(SMemTable *pMemTable, tb_uid_t suid, tb_uid pMemTable->aBucket[idx] = pTbData; pMemTable->nTbData++; - tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn); + (void)tRBTreePut(pMemTable->tbDataTree, pTbData->rbtn); taosWUnLockLatch(&pMemTable->latch); @@ -742,7 +742,7 @@ int32_t tsdbRefMemTable(SMemTable *pMemTable, SQueryNode *pQNode) { int32_t nRef = atomic_fetch_add_32(&pMemTable->nRef, 1); ASSERT(nRef > 0); - vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode); + (void)vnodeBufPoolRegisterQuery(pMemTable->pPool, pQNode); _exit: return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbMerge.c b/source/dnode/vnode/src/tsdb/tsdbMerge.c index 599e7c1a6d..7b40290c05 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMerge.c +++ b/source/dnode/vnode/src/tsdb/tsdbMerge.c @@ -375,13 +375,13 @@ static int32_t tsdbMergeFileSetEnd(SMerger *merger) { // edit file system TAOS_CHECK_GOTO(tsdbFSEditBegin(merger->tsdb->pFS, merger->fopArr, TSDB_FEDIT_MERGE), &lino, _exit); - taosThreadMutexLock(&merger->tsdb->mutex); + (void)taosThreadMutexLock(&merger->tsdb->mutex); code = tsdbFSEditCommit(merger->tsdb->pFS); if (code) { - taosThreadMutexUnlock(&merger->tsdb->mutex); + (void)taosThreadMutexUnlock(&merger->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } - taosThreadMutexUnlock(&merger->tsdb->mutex); + (void)taosThreadMutexUnlock(&merger->tsdb->mutex); _exit: if (code) { @@ -478,10 +478,10 @@ _exit: static int32_t tsdbMergeGetFSet(SMerger *merger) { STFileSet *fset; - taosThreadMutexLock(&merger->tsdb->mutex); + (void)taosThreadMutexLock(&merger->tsdb->mutex); tsdbFSGetFSet(merger->tsdb->pFS, merger->fid, &fset); if (fset == NULL) { - taosThreadMutexUnlock(&merger->tsdb->mutex); + (void)taosThreadMutexUnlock(&merger->tsdb->mutex); return 0; } @@ -489,10 +489,10 @@ static int32_t tsdbMergeGetFSet(SMerger *merger) { int32_t code = tsdbTFileSetInitCopy(merger->tsdb, fset, &merger->fset); if (code) { - taosThreadMutexUnlock(&merger->tsdb->mutex); + (void)taosThreadMutexUnlock(&merger->tsdb->mutex); return code; } - taosThreadMutexUnlock(&merger->tsdb->mutex); + (void)taosThreadMutexUnlock(&merger->tsdb->mutex); return 0; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 2c03603d73..198a010a77 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -63,8 +63,8 @@ int32_t tCreateSttBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t num return code; } -static void freeItem(void* pValue) { - SValue* p = (SValue*) pValue; +static void freeItem(void *pValue) { + SValue *p = (SValue *)pValue; if (IS_VAR_DATA_TYPE(p->type)) { taosMemoryFree(p->pData); } @@ -120,7 +120,7 @@ void destroySttBlockReader(SArray *pLDataIterArray, SSttBlockLoadCostInfo *pLoad continue; } - SSttBlockLoadCostInfo* pCost = &pIter->pBlockLoadInfo->cost; + SSttBlockLoadCostInfo *pCost = &pIter->pBlockLoadInfo->cost; if (pLoadCost != NULL) { pLoadCost->loadBlocks += pCost->loadBlocks; pLoadCost->loadStatisBlocks += pCost->loadStatisBlocks; @@ -380,7 +380,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl pBlockLoadInfo->cost.loadStatisBlocks += num; STbStatisBlock block; - tStatisBlockInit(&block); + TAOS_UNUSED(tStatisBlockInit(&block)); int64_t st = taosGetTimestampUs(); @@ -436,7 +436,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl } } else { SValue vFirst = {0}; - for(int32_t j = 0; j < size; ++j) { + for (int32_t j = 0; j < size; ++j) { taosArrayPush(pBlockLoadInfo->info.pFirstKey, &vFirst); taosArrayPush(pBlockLoadInfo->info.pLastKey, &vFirst); } @@ -445,7 +445,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl STbStatisRecord record = {0}; while (i < rows) { - tStatisBlockGet(&block, i, &record); + (void)tStatisBlockGet(&block, i, &record); if (record.suid != suid) { break; } @@ -476,7 +476,7 @@ static int32_t loadSttStatisticsBlockData(SSttFileReader *pSttFileReader, SSttBl } } - tStatisBlockDestroy(&block); + (void)tStatisBlockDestroy(&block); double el = (taosGetTimestampUs() - st) / 1000.0; pBlockLoadInfo->cost.statisElapsedTime += el; @@ -712,7 +712,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) { } int64_t ts = pData->aTSKEY[i]; - if (!pIter->backward) { // asc + if (!pIter->backward) { // asc if (ts > pIter->timeWindow.ekey) { // no more data break; } else { diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index c75e0d92c0..370d847a33 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -105,10 +105,10 @@ int32_t tsdbClose(STsdb **pTsdb) { tsdbDebug("vgId:%d, tsdb is close at %s, days:%d, keep:%d,%d,%d, keepTimeOffset:%d", TD_VID(pdb->pVnode), pdb->path, pdb->keepCfg.days, pdb->keepCfg.keep0, pdb->keepCfg.keep1, pdb->keepCfg.keep2, pdb->keepCfg.keepTimeOffset); - taosThreadMutexLock(&(*pTsdb)->mutex); + (void)taosThreadMutexLock(&(*pTsdb)->mutex); tsdbMemTableDestroy((*pTsdb)->mem, true); (*pTsdb)->mem = NULL; - taosThreadMutexUnlock(&(*pTsdb)->mutex); + (void)taosThreadMutexUnlock(&(*pTsdb)->mutex); tsdbCloseFS(&(*pTsdb)->pFS); tsdbCloseCache(*pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c index d189b5979b..a454f09e22 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRetention.c +++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c @@ -209,15 +209,15 @@ static int32_t tsdbDoRetentionEnd(SRTNer *rtner) { if (TARRAY2_SIZE(&rtner->fopArr) > 0) { TAOS_CHECK_GOTO(tsdbFSEditBegin(rtner->tsdb->pFS, &rtner->fopArr, TSDB_FEDIT_RETENTION), &lino, _exit); - taosThreadMutexLock(&rtner->tsdb->mutex); + (void)taosThreadMutexLock(&rtner->tsdb->mutex); code = tsdbFSEditCommit(rtner->tsdb->pFS); if (code) { - taosThreadMutexUnlock(&rtner->tsdb->mutex); + (void)taosThreadMutexUnlock(&rtner->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } - taosThreadMutexUnlock(&rtner->tsdb->mutex); + (void)taosThreadMutexUnlock(&rtner->tsdb->mutex); TARRAY2_DESTROY(&rtner->fopArr, NULL); } @@ -315,13 +315,13 @@ static int32_t tsdbRetention(void *arg) { }; // begin task - taosThreadMutexLock(&pTsdb->mutex); + (void)taosThreadMutexLock(&pTsdb->mutex); tsdbBeginTaskOnFileSet(pTsdb, rtnArg->fid, &fset); if (fset && (code = tsdbTFileSetInitCopy(pTsdb, fset, &rtner.fset))) { - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); // do retention if (rtner.fset) { @@ -336,9 +336,9 @@ static int32_t tsdbRetention(void *arg) { _exit: if (rtner.fset) { - taosThreadMutexLock(&pTsdb->mutex); + (void)taosThreadMutexLock(&pTsdb->mutex); tsdbFinishTaskOnFileSet(pTsdb, rtnArg->fid); - taosThreadMutexUnlock(&pTsdb->mutex); + (void)taosThreadMutexUnlock(&pTsdb->mutex); } // clear resources @@ -387,9 +387,9 @@ _exit: int32_t tsdbAsyncRetention(STsdb *tsdb, int64_t now) { int32_t code = 0; - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); code = tsdbAsyncRetentionImpl(tsdb, now, false); - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); return code; } @@ -735,9 +735,9 @@ int32_t tsdbAsyncS3Migrate(STsdb *tsdb, int64_t now) { return 0; } - taosThreadMutexLock(&tsdb->mutex); + (void)taosThreadMutexLock(&tsdb->mutex); code = tsdbAsyncRetentionImpl(tsdb, now, true); - taosThreadMutexUnlock(&tsdb->mutex); + (void)taosThreadMutexUnlock(&tsdb->mutex); if (code) { tsdbError("vgId:%d, %s failed, reason:%s", TD_VID(tsdb->pVnode), __func__, tstrerror(code)); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c index 56364fbc6a..c9e02c5130 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapInfo.c @@ -351,7 +351,7 @@ static STsdbFSetPartList* tsdbSnapGetFSetPartList(STFileSystem* fs) { } int32_t code = 0; - taosThreadMutexLock(&fs->tsdb->mutex); + (void)taosThreadMutexLock(&fs->tsdb->mutex); STFileSet* fset; TARRAY2_FOREACH(fs->fSetArr, fset) { STsdbFSetPartition* pItem = NULL; @@ -364,7 +364,7 @@ static STsdbFSetPartList* tsdbSnapGetFSetPartList(STFileSystem* fs) { code = TARRAY2_SORT_INSERT(pList, pItem, tsdbFSetPartCmprFn); ASSERT(code == 0); } - taosThreadMutexUnlock(&fs->tsdb->mutex); + (void)taosThreadMutexUnlock(&fs->tsdb->mutex); if (code) { TARRAY2_DESTROY(pList, tsdbFSetPartitionClear); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index c7c0135270..3edff5ebcb 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -1022,7 +1022,8 @@ static int32_t tsdbSnapWriteTombData(STsdbSnapWriter* writer, SSnapDataHdr* hdr) code = tsdbSnapWriteDecmprTombBlock(hdr, tombBlock); TSDB_CHECK_CODE(code, lino, _exit); - tTombBlockGet(tombBlock, 0, &record); + code = tTombBlockGet(tombBlock, 0, &record); + TSDB_CHECK_CODE(code, lino, _exit); int32_t fid = tsdbKeyFid(record.skey, writer->minutes, writer->precision); if (!writer->ctx->fsetWriteBegin || fid != writer->ctx->fid) { code = tsdbSnapWriteFileSetEnd(writer); @@ -1045,7 +1046,8 @@ static int32_t tsdbSnapWriteTombData(STsdbSnapWriter* writer, SSnapDataHdr* hdr) ASSERT(writer->ctx->hasData == false); for (int32_t i = 0; i < TOMB_BLOCK_SIZE(tombBlock); ++i) { - tTombBlockGet(tombBlock, i, &record); + code = tTombBlockGet(tombBlock, i, &record); + TSDB_CHECK_CODE(code, lino, _exit); code = tsdbSnapWriteTombRecord(writer, &record); TSDB_CHECK_CODE(code, lino, _exit); @@ -1125,17 +1127,17 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** writer, int8_t rollback) { code = tsdbFSEditAbort(writer[0]->tsdb->pFS); TSDB_CHECK_CODE(code, lino, _exit); } else { - taosThreadMutexLock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexLock(&writer[0]->tsdb->mutex); code = tsdbFSEditCommit(writer[0]->tsdb->pFS); if (code) { - taosThreadMutexUnlock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } writer[0]->tsdb->pFS->fsstate = TSDB_FS_STATE_NORMAL; - taosThreadMutexUnlock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex); } tsdbIterMergerClose(&writer[0]->ctx->tombIterMerger); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c index d7c919bb4b..5b69638b36 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshotRAW.c @@ -65,7 +65,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at line %d since %s, sver:0, ever:%" PRId64 " type:%d", TD_VID(tsdb->pVnode), __func__, lino, tstrerror(code), ever, type); - tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + (void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); taosMemoryFree(reader[0]); reader[0] = NULL; } else { @@ -84,7 +84,7 @@ int32_t tsdbSnapRAWReaderClose(STsdbSnapRAWReader** reader) { STsdb* tsdb = reader[0]->tsdb; TARRAY2_DESTROY(reader[0]->dataReaderArr, tsdbDataFileRAWReaderClose); - tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); + (void)tsdbFSDestroyRefSnapshot(&reader[0]->fsetArr); taosMemoryFree(reader[0]); reader[0] = NULL; @@ -141,7 +141,7 @@ static int32_t tsdbSnapRAWReadFileSetOpenReader(STsdbSnapRAWReader* reader) { _exit: if (code) { - tsdbSnapRAWReadFileSetCloseReader(reader); + (void)tsdbSnapRAWReadFileSetCloseReader(reader); TSDB_ERROR_LOG(TD_VID(reader->tsdb->pVnode), code, lino); } return code; @@ -268,8 +268,8 @@ _exit: } static int32_t tsdbSnapRAWReadEnd(STsdbSnapRAWReader* reader) { - tsdbSnapRAWReadFileSetCloseIter(reader); - tsdbSnapRAWReadFileSetCloseReader(reader); + (void)tsdbSnapRAWReadFileSetCloseIter(reader); + (void)tsdbSnapRAWReadFileSetCloseReader(reader); reader->ctx->fset = NULL; return 0; } @@ -420,7 +420,7 @@ static int32_t tsdbSnapRAWWriteFileSetBegin(STsdbSnapRAWWriter* writer, int32_t int32_t level = tsdbFidLevel(fid, &writer->tsdb->keepCfg, taosGetTimestampSec()); code = tfsAllocDisk(writer->tsdb->pVnode->pTfs, level, &writer->ctx->did); TSDB_CHECK_CODE(code, lino, _exit); - tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); + (void)tfsMkdirRecurAt(writer->tsdb->pVnode->pTfs, writer->tsdb->path, writer->ctx->did); code = tsdbSnapRAWWriteFileSetOpenWriter(writer); TSDB_CHECK_CODE(code, lino, _exit); @@ -485,21 +485,21 @@ int32_t tsdbSnapRAWWriterClose(STsdbSnapRAWWriter** writer, int8_t rollback) { code = tsdbFSEditAbort(writer[0]->tsdb->pFS); TSDB_CHECK_CODE(code, lino, _exit); } else { - taosThreadMutexLock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexLock(&writer[0]->tsdb->mutex); code = tsdbFSEditCommit(writer[0]->tsdb->pFS); if (code) { - taosThreadMutexUnlock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex); TSDB_CHECK_CODE(code, lino, _exit); } writer[0]->tsdb->pFS->fsstate = TSDB_FS_STATE_NORMAL; - taosThreadMutexUnlock(&writer[0]->tsdb->mutex); + (void)taosThreadMutexUnlock(&writer[0]->tsdb->mutex); } TARRAY2_DESTROY(writer[0]->fopArr, NULL); - tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr); + (void)tsdbFSDestroyCopySnapshot(&writer[0]->fsetArr); taosMemoryFree(writer[0]); writer[0] = NULL; diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index a552f9bcca..779e6146e8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -55,7 +55,7 @@ int32_t tsdbSttFileReaderOpen(const char *fname, const SSttFileReaderConfig *con TAOS_CHECK_GOTO(tsdbOpenFile(fname, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit); } else { char fname1[TSDB_FILENAME_LEN]; - tsdbTFileName(config->tsdb, config->file, fname1); + (void)tsdbTFileName(config->tsdb, config->file, fname1); TAOS_CHECK_GOTO(tsdbOpenFile(fname1, config->tsdb, TD_FILE_READ, &reader[0]->fd, 0), &lino, _exit); } @@ -91,7 +91,7 @@ _exit: if (code) { tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(config->tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); - tsdbSttFileReaderClose(reader); + (void)tsdbSttFileReaderClose(reader); } return code; } @@ -401,7 +401,7 @@ int32_t tsdbSttFileReadStatisBlock(SSttFileReader *reader, const SStatisBlk *sta &lino, _exit); // decode data - tStatisBlockClear(statisBlock); + TAOS_UNUSED(tStatisBlockClear(statisBlock)); statisBlock->numOfPKs = statisBlk->numOfPKs; statisBlock->numOfRecords = statisBlk->numRec; SBufferReader br = BUFFER_READER_INITIALIZER(0, buffer0); @@ -574,11 +574,11 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) { statisBlk.cmprAlg = writer->config->cmprAlg; statisBlk.numOfPKs = statisBlock->numOfPKs; - tStatisBlockGet(statisBlock, 0, &record); + (void)tStatisBlockGet(statisBlock, 0, &record); statisBlk.minTbid.suid = record.suid; statisBlk.minTbid.uid = record.uid; - tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); + (void)tStatisBlockGet(statisBlock, statisBlock->numOfRecords - 1, &record); statisBlk.maxTbid.suid = record.suid; statisBlk.maxTbid.uid = record.uid; @@ -636,7 +636,7 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) { TAOS_CHECK_GOTO(TARRAY2_APPEND_PTR(writer->statisBlkArray, &statisBlk), &lino, _exit); - tStatisBlockClear(writer->staticBlock); + TAOS_UNUSED(tStatisBlockClear(writer->staticBlock)); _exit: if (code) { @@ -790,7 +790,7 @@ static int32_t tsdbSttFWriterDoOpen(SSttFileWriter *writer) { int32_t flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC; char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(writer->config->tsdb, writer->file, fname); + (void)tsdbTFileName(writer->config->tsdb, writer->file, fname); TAOS_CHECK_GOTO(tsdbOpenFile(fname, writer->config->tsdb, flag, &writer->fd, 0), &lino, _exit); uint8_t hdr[TSDB_FHDR_SIZE] = {0}; @@ -822,7 +822,7 @@ static void tsdbSttFWriterDoClose(SSttFileWriter *writer) { tDestroyTSchema(writer->skmRow->pTSchema); tDestroyTSchema(writer->skmTb->pTSchema); tTombBlockDestroy(writer->tombBlock); - tStatisBlockDestroy(writer->staticBlock); + (void)tStatisBlockDestroy(writer->staticBlock); tBlockDataDestroy(writer->blockData); TARRAY2_DESTROY(writer->tombBlkArray, NULL); TARRAY2_DESTROY(writer->statisBlkArray, NULL); @@ -860,7 +860,7 @@ static int32_t tsdbSttFWriterCloseCommit(SSttFileWriter *writer, TFileOpArray *o .fid = writer->config->fid, .nf = writer->file[0], }; - tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); + (void)tsdbTFileUpdVerRange(&op.nf, writer->ctx->range); TAOS_CHECK_GOTO(TARRAY2_APPEND(opArray, op), &lino, _exit); @@ -874,7 +874,7 @@ _exit: static int32_t tsdbSttFWriterCloseAbort(SSttFileWriter *writer) { char fname[TSDB_FILENAME_LEN]; - tsdbTFileName(writer->config->tsdb, writer->file, fname); + (void)tsdbTFileName(writer->config->tsdb, writer->file, fname); tsdbCloseFile(&writer->fd); (void)taosRemoveFile(fname); return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c index ef116e2642..6d2006eaa1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUpgrade.c +++ b/source/dnode/vnode/src/tsdb/tsdbUpgrade.c @@ -167,7 +167,7 @@ _exit: tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(tsdb->pVnode), __func__, __FILE__, lino, tstrerror(code)); } TARRAY2_DESTROY(ctx->brinBlkArray, NULL); - tBrinBlockDestroy(ctx->brinBlock); + (void)tBrinBlockDestroy(ctx->brinBlock); tBlockDataDestroy(ctx->blockData); tMapDataClear(ctx->mDataBlk); taosArrayDestroy(ctx->aBlockIdx); diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil2.c b/source/dnode/vnode/src/tsdb/tsdbUtil2.c index 97fea598cd..7ada3085b1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil2.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil2.c @@ -16,35 +16,26 @@ #include "tsdbUtil2.h" // SDelBlock ---------- -int32_t tTombBlockInit(STombBlock *tombBlock) { - int32_t code; - +void tTombBlockInit(STombBlock *tombBlock) { tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TAOS_CHECK_GOTO(tBufferInit(&tombBlock->buffers[i]), NULL, _exit); + tBufferInit(&tombBlock->buffers[i]); } - -_exit: - if (code) { - TAOS_UNUSED(tTombBlockDestroy(tombBlock)); - } - return code; + return; } -int32_t tTombBlockDestroy(STombBlock *tombBlock) { +void tTombBlockDestroy(STombBlock *tombBlock) { tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TAOS_UNUSED(tBufferDestroy(&tombBlock->buffers[i])); + tBufferDestroy(&tombBlock->buffers[i]); } - return 0; } -int32_t tTombBlockClear(STombBlock *tombBlock) { +void tTombBlockClear(STombBlock *tombBlock) { tombBlock->numOfRecords = 0; for (int32_t i = 0; i < TOMB_RECORD_ELEM_NUM; ++i) { - TAOS_UNUSED(tBufferClear(&tombBlock->buffers[i])); + tBufferClear(&tombBlock->buffers[i]); } - return 0; } int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record) { @@ -79,12 +70,12 @@ int32_t tTombRecordCompare(const STombRecord *r1, const STombRecord *r2) { // STbStatisBlock ---------- int32_t tStatisBlockInit(STbStatisBlock *statisBlock) { - int32_t code; + int32_t code = 0; statisBlock->numOfPKs = 0; statisBlock->numOfRecords = 0; for (int32_t i = 0; i < ARRAY_SIZE(statisBlock->buffers); ++i) { - TAOS_CHECK_GOTO(tBufferInit(&statisBlock->buffers[i]), NULL, _exit); + tBufferInit(&statisBlock->buffers[i]); } for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { TAOS_CHECK_GOTO(tValueColumnInit(&statisBlock->firstKeyPKs[i]), NULL, _exit); @@ -244,7 +235,7 @@ int32_t tBrinBlockInit(SBrinBlock *brinBlock) { brinBlock->numOfPKs = 0; brinBlock->numOfRecords = 0; for (int32_t i = 0; i < ARRAY_SIZE(brinBlock->buffers); ++i) { - TAOS_CHECK_GOTO(tBufferInit(&brinBlock->buffers[i]), NULL, _exit); + tBufferInit(&brinBlock->buffers[i]); } for (int32_t i = 0; i < TD_MAX_PK_COLS; ++i) { TAOS_CHECK_GOTO(tValueColumnInit(&brinBlock->firstKeyPKs[i]), NULL, _exit); @@ -253,7 +244,7 @@ int32_t tBrinBlockInit(SBrinBlock *brinBlock) { _exit: if (code) { - TAOS_UNUSED(tBrinBlockDestroy(brinBlock)); + (void)tBrinBlockDestroy(brinBlock); } return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil2.h b/source/dnode/vnode/src/tsdb/tsdbUtil2.h index 71f47a5f8e..d9d2892165 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil2.h +++ b/source/dnode/vnode/src/tsdb/tsdbUtil2.h @@ -65,9 +65,9 @@ typedef TARRAY2(STombBlk) TTombBlkArray; #define TOMB_BLOCK_SIZE(db) ((db)->numOfRecords) -int32_t tTombBlockInit(STombBlock *tombBlock); -int32_t tTombBlockDestroy(STombBlock *tombBlock); -int32_t tTombBlockClear(STombBlock *tombBlock); +void tTombBlockInit(STombBlock *tombBlock); +void tTombBlockDestroy(STombBlock *tombBlock); +void tTombBlockClear(STombBlock *tombBlock); int32_t tTombBlockPut(STombBlock *tombBlock, const STombRecord *record); int32_t tTombBlockGet(STombBlock *tombBlock, int32_t idx, STombRecord *record); int32_t tTombRecordCompare(const STombRecord *record1, const STombRecord *record2); diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 126c394f54..cd4450cd7b 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -171,12 +171,12 @@ static int32_t vnodeAsyncTaskDone(SVAsync *async, SVATask *task) { async->numTasks--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } else if (task->numWait == 1) { - taosThreadCondSignal(&task->waitCond); + (void)taosThreadCondSignal(&task->waitCond); } else { - taosThreadCondBroadcast(&task->waitCond); + (void)taosThreadCondBroadcast(&task->waitCond); } return 0; } @@ -195,7 +195,7 @@ static int32_t vnodeAsyncCancelAllTasks(SVAsync *async, SArray *cancelArray) { .arg = task->arg, })); } - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } } } @@ -213,22 +213,22 @@ static void *vnodeAsyncLoop(void *arg) { setThreadName(async->label); for (;;) { - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); // finish last running task if (worker->runningTask != NULL) { - vnodeAsyncTaskDone(async, worker->runningTask); + (void)vnodeAsyncTaskDone(async, worker->runningTask); worker->runningTask = NULL; } for (;;) { if (async->stop || worker->workerId >= async->numWorkers) { if (async->stop) { // cancel all tasks - vnodeAsyncCancelAllTasks(async, cancelArray); + (void)vnodeAsyncCancelAllTasks(async, cancelArray); } worker->state = EVA_WORKER_STATE_STOP; async->numLaunchWorkers--; - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); goto _exit; } @@ -259,7 +259,7 @@ static void *vnodeAsyncLoop(void *arg) { if (worker->runningTask == NULL) { worker->state = EVA_WORKER_STATE_IDLE; async->numIdleWorkers++; - taosThreadCondWait(&async->hasTask, &async->mutex); + (void)taosThreadCondWait(&async->hasTask, &async->mutex); async->numIdleWorkers--; worker->state = EVA_WORKER_STATE_ACTIVE; } else { @@ -268,10 +268,10 @@ static void *vnodeAsyncLoop(void *arg) { } } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); // do run the task - worker->runningTask->execute(worker->runningTask->arg); + (void)worker->runningTask->execute(worker->runningTask->arg); } _exit: @@ -334,8 +334,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { strcpy((char *)((*async) + 1), label); (*async)->label = (const char *)((*async) + 1); - taosThreadMutexInit(&(*async)->mutex, NULL); - taosThreadCondInit(&(*async)->hasTask, NULL); + (void)taosThreadMutexInit(&(*async)->mutex, NULL); + (void)taosThreadCondInit(&(*async)->hasTask, NULL); (*async)->stop = false; // worker @@ -356,8 +356,8 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { (*async)->chList.next = &(*async)->chList; ret = vHashInit(&(*async)->channelTable, vnodeAsyncChannelHash, vnodeAsyncChannelCompare); if (ret != 0) { - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); taosMemoryFree(*async); return ret; } @@ -371,9 +371,9 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) { } ret = vHashInit(&(*async)->taskTable, vnodeAsyncTaskHash, vnodeAsyncTaskCompare); if (ret != 0) { - vHashDestroy(&(*async)->channelTable); - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)vHashDestroy(&(*async)->channelTable); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); taosMemoryFree(*async); return ret; } @@ -387,22 +387,22 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { } // set stop and broadcast - taosThreadMutexLock(&(*async)->mutex); + (void)taosThreadMutexLock(&(*async)->mutex); (*async)->stop = true; taosThreadCondBroadcast(&(*async)->hasTask); - taosThreadMutexUnlock(&(*async)->mutex); + (void)taosThreadMutexUnlock(&(*async)->mutex); // join all workers for (int32_t i = 0; i < VNODE_ASYNC_MAX_WORKERS; i++) { - taosThreadMutexLock(&(*async)->mutex); + (void)taosThreadMutexLock(&(*async)->mutex); EVWorkerState state = (*async)->workers[i].state; - taosThreadMutexUnlock(&(*async)->mutex); + (void)taosThreadMutexUnlock(&(*async)->mutex); if (state == EVA_WORKER_STATE_UINIT) { continue; } - taosThreadJoin((*async)->workers[i].thread, NULL); + (void)taosThreadJoin((*async)->workers[i].thread, NULL); ASSERT((*async)->workers[i].state == EVA_WORKER_STATE_STOP); (*async)->workers[i].state = EVA_WORKER_STATE_UINIT; } @@ -425,11 +425,11 @@ static int32_t vnodeAsyncDestroy(SVAsync **async) { ASSERT((*async)->numChannels == 0); ASSERT((*async)->numTasks == 0); - taosThreadMutexDestroy(&(*async)->mutex); - taosThreadCondDestroy(&(*async)->hasTask); + (void)taosThreadMutexDestroy(&(*async)->mutex); + (void)taosThreadCondDestroy(&(*async)->hasTask); - vHashDestroy(&(*async)->channelTable); - vHashDestroy(&(*async)->taskTable); + (void)vHashDestroy(&(*async)->channelTable); + (void)vHashDestroy(&(*async)->taskTable); taosMemoryFree(*async); *async = NULL; @@ -442,11 +442,11 @@ static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { if (async->workers[i].state == EVA_WORKER_STATE_ACTIVE) { continue; } else if (async->workers[i].state == EVA_WORKER_STATE_STOP) { - taosThreadJoin(async->workers[i].thread, NULL); + (void)taosThreadJoin(async->workers[i].thread, NULL); async->workers[i].state = EVA_WORKER_STATE_UINIT; } - taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); + (void)taosThreadCreate(&async->workers[i].thread, NULL, vnodeAsyncLoop, &async->workers[i]); async->workers[i].state = EVA_WORKER_STATE_ACTIVE; async->numLaunchWorkers++; break; @@ -461,20 +461,20 @@ int32_t vnodeAsyncOpen(int32_t numOfThreads) { // vnode-commit code = vnodeAsyncInit(&vnodeAsyncs[1], "vnode-commit"); TSDB_CHECK_CODE(code, lino, _exit); - vnodeAsyncSetWorkers(1, numOfThreads); + (void)vnodeAsyncSetWorkers(1, numOfThreads); // vnode-merge code = vnodeAsyncInit(&vnodeAsyncs[2], "vnode-merge"); TSDB_CHECK_CODE(code, lino, _exit); - vnodeAsyncSetWorkers(2, numOfThreads); + (void)vnodeAsyncSetWorkers(2, numOfThreads); _exit: return code; } int32_t vnodeAsyncClose() { - vnodeAsyncDestroy(&vnodeAsyncs[1]); - vnodeAsyncDestroy(&vnodeAsyncs[2]); + (void)vnodeAsyncDestroy(&vnodeAsyncs[1]); + (void)vnodeAsyncDestroy(&vnodeAsyncs[2]); return 0; } @@ -501,10 +501,10 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec task->arg = arg; task->state = EVA_TASK_STATE_WAITTING; task->numWait = 0; - taosThreadCondInit(&task->waitCond, NULL); + (void)taosThreadCondInit(&task->waitCond, NULL); // schedule task - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); if (channelID->id == 0) { task->channel = NULL; @@ -512,10 +512,10 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec SVAChannel channel = { .channelId = channelID->id, }; - vHashGet(async->channelTable, &channel, (void **)&task->channel); + (void)vHashGet(async->channelTable, &channel, (void **)&task->channel); if (task->channel == NULL) { - taosThreadMutexUnlock(&async->mutex); - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadMutexUnlock(&async->mutex); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); return TSDB_CODE_INVALID_PARA; } @@ -526,8 +526,8 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec // add task to hash table int32_t ret = vHashPut(async->taskTable, task); if (ret != 0) { - taosThreadMutexUnlock(&async->mutex); - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadMutexUnlock(&async->mutex); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); return ret; } @@ -548,9 +548,9 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec // signal worker or launch new worker if (async->numIdleWorkers > 0) { - taosThreadCondSignal(&(async->hasTask)); + (void)taosThreadCondSignal(&(async->hasTask)); } else if (async->numLaunchWorkers < async->numWorkers) { - vnodeAsyncLaunchWorker(async); + (void)vnodeAsyncLaunchWorker(async); } } else if (task->channel->scheduled->state == EVA_TASK_STATE_RUNNING || priority >= VATASK_PIORITY(task->channel->scheduled)) { @@ -580,7 +580,7 @@ int32_t vnodeAsync(SVAChannelID *channelID, EVAPriority priority, int32_t (*exec task->prev->next = task; } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); if (taskID != NULL) { taskID->async = channelID->async; @@ -601,21 +601,21 @@ int32_t vnodeAWait(SVATaskID *taskID) { .taskId = taskID->id, }; - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->taskTable, &task2, (void **)&task); + (void)vHashGet(async->taskTable, &task2, (void **)&task); if (task) { task->numWait++; - taosThreadCondWait(&task->waitCond, &async->mutex); + (void)taosThreadCondWait(&task->waitCond, &async->mutex); task->numWait--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); return 0; } @@ -634,22 +634,22 @@ int32_t vnodeACancel(SVATaskID *taskID) { void (*cancel)(void *) = NULL; void *arg = NULL; - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->taskTable, &task2, (void **)&task); + (void)vHashGet(async->taskTable, &task2, (void **)&task); if (task) { if (task->state == EVA_TASK_STATE_WAITTING) { cancel = task->cancel; arg = task->arg; task->next->prev = task->prev; task->prev->next = task->next; - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } else { ret = TSDB_CODE_FAILED; } } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); if (cancel) { cancel(arg); @@ -663,12 +663,12 @@ int32_t vnodeAsyncSetWorkers(int64_t asyncID, int32_t numWorkers) { return TSDB_CODE_INVALID_PARA; } SVAsync *async = vnodeAsyncs[asyncID]; - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); async->numWorkers = numWorkers; if (async->numIdleWorkers > 0) { taosThreadCondBroadcast(&async->hasTask); } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); return 0; } @@ -693,14 +693,14 @@ int32_t vnodeAChannelInit(int64_t asyncID, SVAChannelID *channelID) { channel->scheduled = NULL; // register channel - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); channel->channelId = channelID->id = ++async->nextChannelId; // add to hash table int32_t ret = vHashPut(async->channelTable, channel); if (ret != 0) { - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); taosMemoryFree(channel); return ret; } @@ -713,7 +713,7 @@ int32_t vnodeAChannelInit(int64_t asyncID, SVAChannelID *channelID) { async->numChannels++; - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); channelID->async = asyncID; return 0; @@ -734,14 +734,14 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { return TSDB_CODE_OUT_OF_MEMORY; } - taosThreadMutexLock(&async->mutex); + (void)taosThreadMutexLock(&async->mutex); - vHashGet(async->channelTable, &channel2, (void **)&channel); + (void)vHashGet(async->channelTable, &channel2, (void **)&channel); if (channel) { // unregister channel channel->next->prev = channel->prev; channel->prev->next = channel->next; - vHashDrop(async->channelTable, channel); + (void)vHashDrop(async->channelTable, channel); async->numChannels--; // cancel all waiting tasks @@ -756,7 +756,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = task->arg, })); } - vnodeAsyncTaskDone(async, task); + (void)vnodeAsyncTaskDone(async, task); } } @@ -771,7 +771,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { .arg = channel->scheduled->arg, })); } - vnodeAsyncTaskDone(async, channel->scheduled); + (void)vnodeAsyncTaskDone(async, channel->scheduled); } taosMemoryFree(channel); } else { @@ -779,10 +779,10 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { // wait task SVATask *task = channel->scheduled; task->numWait++; - taosThreadCondWait(&task->waitCond, &async->mutex); + (void)taosThreadCondWait(&task->waitCond, &async->mutex); task->numWait--; if (task->numWait == 0) { - taosThreadCondDestroy(&task->waitCond); + (void)taosThreadCondDestroy(&task->waitCond); taosMemoryFree(task); } @@ -793,7 +793,7 @@ int32_t vnodeAChannelDestroy(SVAChannelID *channelID, bool waitRunning) { } } - taosThreadMutexUnlock(&async->mutex); + (void)taosThreadMutexUnlock(&async->mutex); for (int32_t i = 0; i < taosArrayGetSize(cancelArray); i++) { SVATaskCancelInfo *cancel = (SVATaskCancelInfo *)taosArrayGet(cancelArray, i); cancel->cancel(cancel->arg); diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index f3c2693b75..cbd6fbbe52 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -26,7 +26,7 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu memset(pPool, 0, sizeof(SVBufPool)); // query handle list - taosThreadMutexInit(&pPool->mutex, NULL); + (void)taosThreadMutexInit(&pPool->mutex, NULL); pPool->nQuery = 0; pPool->qList.pNext = &pPool->qList; pPool->qList.ppNext = &pPool->qList.pNext; @@ -61,10 +61,10 @@ static int32_t vnodeBufPoolCreate(SVnode *pVnode, int32_t id, int64_t size, SVBu static int vnodeBufPoolDestroy(SVBufPool *pPool) { vnodeBufPoolReset(pPool); if (pPool->lock) { - taosThreadSpinDestroy(pPool->lock); + (void)taosThreadSpinDestroy(pPool->lock); taosMemoryFree((void *)pPool->lock); } - taosThreadMutexDestroy(&pPool->mutex); + (void)taosThreadMutexDestroy(&pPool->mutex); taosMemoryFree(pPool); return 0; } @@ -77,7 +77,7 @@ int vnodeOpenBufPool(SVnode *pVnode) { int32_t code; if ((code = vnodeBufPoolCreate(pVnode, i, size, &pVnode->aBufPool[i]))) { vError("vgId:%d, failed to open vnode buffer pool since %s", TD_VID(pVnode), tstrerror(terrno)); - vnodeCloseBufPool(pVnode); + (void)vnodeCloseBufPool(pVnode); return code; } @@ -93,7 +93,7 @@ int vnodeOpenBufPool(SVnode *pVnode) { int vnodeCloseBufPool(SVnode *pVnode) { for (int32_t i = 0; i < VNODE_BUFPOOL_SEGMENTS; i++) { if (pVnode->aBufPool[i]) { - vnodeBufPoolDestroy(pVnode->aBufPool[i]); + (void)vnodeBufPoolDestroy(pVnode->aBufPool[i]); pVnode->aBufPool[i] = NULL; } } @@ -141,7 +141,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) { pNode = taosMemoryMalloc(sizeof(*pNode) + size); if (pNode == NULL) { if (pPool->lock) { - taosThreadSpinUnlock(pPool->lock); + (void)taosThreadSpinUnlock(pPool->lock); } return NULL; } @@ -155,7 +155,7 @@ void *vnodeBufPoolMallocAligned(SVBufPool *pPool, int size) { pPool->size = pPool->size + sizeof(*pNode) + size; } - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return p; } @@ -174,7 +174,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) { // allocate a new node pNode = taosMemoryMalloc(sizeof(*pNode) + size); if (pNode == NULL) { - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return NULL; } @@ -187,7 +187,7 @@ void *vnodeBufPoolMalloc(SVBufPool *pPool, int size) { pPool->size = pPool->size + sizeof(*pNode) + size; } - if (pPool->lock) taosThreadSpinUnlock(pPool->lock); + if (pPool->lock) (void)taosThreadSpinUnlock(pPool->lock); return p; } @@ -223,7 +223,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) { vInfo("vgId:%d, buffer pool of id %d size changed from %" PRId64 " to %" PRId64, TD_VID(pVnode), pPool->id, pPool->node.size, size); - vnodeBufPoolDestroy(pPool); + (void)vnodeBufPoolDestroy(pPool); pPool = pNewPool; pVnode->aBufPool[pPool->id] = pPool; } @@ -234,7 +234,7 @@ void vnodeBufPoolAddToFreeList(SVBufPool *pPool) { vnodeBufPoolReset(pPool); pPool->freeNext = pVnode->freeList; pVnode->freeList = pPool; - taosThreadCondSignal(&pVnode->poolNotEmpty); + (void)taosThreadCondSignal(&pVnode->poolNotEmpty); } void vnodeBufPoolUnRef(SVBufPool *pPool, bool proactive) { @@ -242,7 +242,9 @@ void vnodeBufPoolUnRef(SVBufPool *pPool, bool proactive) { SVnode *pVnode = pPool->pVnode; - if (proactive) taosThreadMutexLock(&pVnode->mutex); + if (proactive) { + (void)taosThreadMutexLock(&pVnode->mutex); + } if (atomic_sub_fetch_32(&pPool->nRef, 1) > 0) goto _exit; @@ -267,12 +269,14 @@ void vnodeBufPoolUnRef(SVBufPool *pPool, bool proactive) { vnodeBufPoolAddToFreeList(pPool); _exit: - if (proactive) taosThreadMutexUnlock(&pVnode->mutex); + if (proactive) { + (void)taosThreadMutexUnlock(&pVnode->mutex); + } return; } int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) { - taosThreadMutexLock(&pPool->mutex); + (void)taosThreadMutexLock(&pPool->mutex); pQNode->pNext = pPool->qList.pNext; pQNode->ppNext = &pPool->qList.pNext; @@ -280,20 +284,24 @@ int32_t vnodeBufPoolRegisterQuery(SVBufPool *pPool, SQueryNode *pQNode) { pPool->qList.pNext = pQNode; pPool->nQuery++; - taosThreadMutexUnlock(&pPool->mutex); + (void)taosThreadMutexUnlock(&pPool->mutex); return 0; } void vnodeBufPoolDeregisterQuery(SVBufPool *pPool, SQueryNode *pQNode, bool proactive) { int32_t code = 0; - if (proactive) taosThreadMutexLock(&pPool->mutex); + if (proactive) { + (void)taosThreadMutexLock(&pPool->mutex); + } pQNode->pNext->ppNext = pQNode->ppNext; *pQNode->ppNext = pQNode->pNext; pPool->nQuery--; - if (proactive) taosThreadMutexUnlock(&pPool->mutex); + if (proactive) { + (void)taosThreadMutexUnlock(&pPool->mutex); + } } int32_t vnodeBufPoolRecycle(SVBufPool *pPool) { @@ -303,7 +311,7 @@ int32_t vnodeBufPoolRecycle(SVBufPool *pPool) { vDebug("vgId:%d, recycle buffer pool %p of id %d", TD_VID(pVnode), pPool, pPool->id); - taosThreadMutexLock(&pPool->mutex); + (void)taosThreadMutexLock(&pPool->mutex); SQueryNode *pNode = pPool->qList.pNext; while (pNode != &pPool->qList) { @@ -319,6 +327,6 @@ int32_t vnodeBufPoolRecycle(SVBufPool *pPool) { } _exit: - taosThreadMutexUnlock(&pPool->mutex); + (void)taosThreadMutexUnlock(&pPool->mutex); return code; } diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index 12e4fe7753..e2db87173d 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -127,7 +127,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) { if (pNodeRetentions == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - tjsonAddItemToObject(pJson, "retentions", pNodeRetentions); + TAOS_CHECK_RETURN(tjsonAddItemToObject(pJson, "retentions", pNodeRetentions)); for (int32_t i = 0; i < nRetention; ++i) { SJson *pNodeRetention = tjsonCreateObject(); const SRetention *pRetention = pCfg->tsdbCfg.retentions + i; @@ -353,7 +353,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { if (info == NULL) return -1; tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code); if (code) return code; - tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); + (void)tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code); if (code) return code; tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code); diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 96fb461188..f7174d9a5f 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -65,7 +65,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) { int32_t code = 0; int32_t lino = 0; - taosThreadMutexLock(&pVnode->mutex); + (void)taosThreadMutexLock(&pVnode->mutex); int32_t nTry = 0; for (;;) { @@ -91,7 +91,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) { struct timeval tv; struct timespec ts; - taosGetTimeOfDay(&tv); + (void)taosGetTimeOfDay(&tv); ts.tv_nsec = tv.tv_usec * 1000 + WAIT_TIME_MILI_SEC * 1000000; if (ts.tv_nsec > 999999999l) { ts.tv_sec = tv.tv_sec + 1; @@ -110,7 +110,7 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) { } _exit: - taosThreadMutexUnlock(&pVnode->mutex); + (void)taosThreadMutexUnlock(&pVnode->mutex); if (code) { vError("vgId:%d, %s failed at line %d since %s", TD_VID(pVnode), __func__, lino, tstrerror(code)); } @@ -150,7 +150,7 @@ int vnodeShouldCommit(SVnode *pVnode, bool atExit) { bool diskAvail = osDataSpaceAvailable(); bool needCommit = false; - taosThreadMutexLock(&pVnode->mutex); + (void)taosThreadMutexLock(&pVnode->mutex); if (pVnode->inUse && diskAvail) { needCommit = (pVnode->inUse->size > pVnode->inUse->node.size) || (atExit && (pVnode->inUse->size > 0 || pVnode->pMeta->changed || @@ -162,7 +162,7 @@ int vnodeShouldCommit(SVnode *pVnode, bool atExit) { TD_VID(pVnode), needCommit, diskAvail, pVnode->inUse ? pVnode->inUse->size : 0, pVnode->inUse ? pVnode->inUse->node.size : 0, pVnode->pMeta->changed, pVnode->state.applied, pVnode->state.committed); - taosThreadMutexUnlock(&pVnode->mutex); + (void)taosThreadMutexUnlock(&pVnode->mutex); return needCommit; } @@ -199,7 +199,7 @@ _exit: vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d selfIndex:%d changeVersion:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum, pInfo->config.syncCfg.myIndex, pInfo->config.syncCfg.changeVersion); } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); taosMemoryFree(data); return code; } @@ -259,7 +259,7 @@ _exit: vError("vgId:%d %s failed at %s:%d since %s", pInfo->config.vgId, __func__, __FILE__, lino, tstrerror(code)); } taosMemoryFree(pData); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return code; } @@ -270,7 +270,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { int64_t lastCommitted = pInfo->info.state.committed; // wait last commit task - vnodeAWait(&pVnode->commitTask); + (void)vnodeAWait(&pVnode->commitTask); code = syncNodeGetConfig(pVnode->sync, &pVnode->config.syncCfg); TSDB_CHECK_CODE(code, lino, _exit); @@ -285,7 +285,7 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { pInfo->txn = metaGetTxn(pVnode->pMeta); // save info - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); vDebug("vgId:%d, save config while prepare commit", TD_VID(pVnode)); code = vnodeSaveInfo(dir, &pInfo->info); @@ -299,11 +299,11 @@ static int32_t vnodePrepareCommit(SVnode *pVnode, SCommitInfo *pInfo) { code = smaPrepareAsyncCommit(pVnode->pSma); TSDB_CHECK_CODE(code, lino, _exit); - taosThreadMutexLock(&pVnode->mutex); + (void)taosThreadMutexLock(&pVnode->mutex); ASSERT(pVnode->onCommit == NULL); pVnode->onCommit = pVnode->inUse; pVnode->inUse = NULL; - taosThreadMutexUnlock(&pVnode->mutex); + (void)taosThreadMutexUnlock(&pVnode->mutex); _exit: if (code) { @@ -316,7 +316,7 @@ _exit: return code; } static void vnodeReturnBufPool(SVnode *pVnode) { - taosThreadMutexLock(&pVnode->mutex); + (void)taosThreadMutexLock(&pVnode->mutex); SVBufPool *pPool = pVnode->onCommit; int32_t nRef = atomic_sub_fetch_32(&pPool->nRef, 1); @@ -340,7 +340,7 @@ static void vnodeReturnBufPool(SVnode *pVnode) { ASSERT(0); } - taosThreadMutexUnlock(&pVnode->mutex); + (void)taosThreadMutexUnlock(&pVnode->mutex); } static int32_t vnodeCommit(void *arg) { int32_t code = 0; @@ -395,8 +395,8 @@ _exit: } int vnodeSyncCommit(SVnode *pVnode) { - vnodeAsyncCommit(pVnode); - vnodeAWait(&pVnode->commitTask); + (void)vnodeAsyncCommit(pVnode); + (void)vnodeAWait(&pVnode->commitTask); return 0; } @@ -416,9 +416,9 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); - syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); + (void)syncBeginSnapshot(pVnode->sync, pInfo->info.state.committed); code = tsdbCommitBegin(pVnode->pTsdb, pInfo); TSDB_CHECK_CODE(code, lino, _exit); @@ -455,7 +455,7 @@ static int vnodeCommitImpl(SCommitInfo *pInfo) { return -1; } - syncEndSnapshot(pVnode->sync); + (void)syncEndSnapshot(pVnode->sync); _exit: if (code) { @@ -470,7 +470,7 @@ bool vnodeShouldRollback(SVnode *pVnode) { char tFName[TSDB_FILENAME_LEN] = {0}; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); offset = strlen(tFName); snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP); @@ -481,7 +481,7 @@ void vnodeRollback(SVnode *pVnode) { char tFName[TSDB_FILENAME_LEN] = {0}; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, tFName, TSDB_FILENAME_LEN); offset = strlen(tFName); snprintf(tFName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME_TMP); diff --git a/source/dnode/vnode/src/vnd/vnodeHash.c b/source/dnode/vnode/src/vnd/vnodeHash.c index 093b5056ed..00fc2dfc00 100644 --- a/source/dnode/vnode/src/vnd/vnodeHash.c +++ b/source/dnode/vnode/src/vnd/vnodeHash.c @@ -98,7 +98,7 @@ int32_t vHashPut(SVHashTable* ht, void* obj) { } if (ht->numEntries >= ht->numBuckets) { - vHashRehash(ht, ht->numBuckets * 2); + (void)vHashRehash(ht, ht->numBuckets * 2); bucketIndex = ht->hash(obj) % ht->numBuckets; } @@ -144,7 +144,7 @@ int32_t vHashDrop(SVHashTable* ht, const void* obj) { taosMemoryFree(tmp); ht->numEntries--; if (ht->numBuckets > VNODE_HASH_DEFAULT_NUM_BUCKETS && ht->numEntries < ht->numBuckets / 4) { - vHashRehash(ht, ht->numBuckets / 2); + (void)vHashRehash(ht, ht->numBuckets / 2); } return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeModule.c b/source/dnode/vnode/src/vnd/vnodeModule.c index 228cc9e0b2..8b7de7058c 100644 --- a/source/dnode/vnode/src/vnd/vnodeModule.c +++ b/source/dnode/vnode/src/vnd/vnodeModule.c @@ -31,7 +31,7 @@ int vnodeInit(int nthreads) { void vnodeCleanup() { if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return; - vnodeAsyncClose(); + (void)vnodeAsyncClose(); walCleanUp(); smaCleanUp(); } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index fb835fd0c2..dacb565ee5 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -53,7 +53,7 @@ int32_t vnodeCreate(const char *path, SVnodeCfg *pCfg, int32_t diskPrimary, STfs vError("vgId:%d, failed to prepare vnode dir since %s, path: %s", pCfg->vgId, strerror(errno), path); return TAOS_SYSTEM_ERROR(errno); } - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (pCfg) { info.config = *pCfg; @@ -88,7 +88,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t char dir[TSDB_FILENAME_LEN] = {0}; int32_t ret = 0; - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); ret = vnodeLoadInfo(dir, &info); if (ret < 0) { @@ -221,7 +221,7 @@ int32_t vnodeAlterHashRange(const char *srcPath, const char *dstPath, SAlterVnod char dir[TSDB_FILENAME_LEN] = {0}; int32_t ret = 0; - vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); ret = vnodeLoadInfo(dir, &info); if (ret < 0) { @@ -283,7 +283,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s char dir[TSDB_FILENAME_LEN] = {0}; int32_t code = 0; - vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(dstPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (vnodeLoadInfo(dir, &info) == 0) { if (info.config.vgId != dstVgId) { vError("vgId:%d, unexpected vnode config.vgId:%d", dstVgId, info.config.vgId); @@ -292,7 +292,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s return dstVgId; } - vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(srcPath, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); if (vnodeLoadInfo(dir, &info) < 0) { vError("vgId:%d, failed to read vnode config from %s since %s", srcVgId, srcPath, tstrerror(terrno)); return -1; @@ -317,7 +317,7 @@ int32_t vnodeRestoreVgroupId(const char *srcPath, const char *dstPath, int32_t s void vnodeDestroy(int32_t vgId, const char *path, STfs *pTfs, int32_t nodeId) { vInfo("path:%s is removed while destroy vnode", path); - tfsRmdir(pTfs, path); + (void)tfsRmdir(pTfs, path); // int32_t nlevel = tfsGetLevel(pTfs); if (nodeId > 0 && vgId > 0 /*&& nlevel > 1*/ && tsS3Enabled) { @@ -351,7 +351,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC vError("failed to open vnode from %s since %s. diskPrimary:%d", path, terrstr(), diskPrimary); return NULL; } - vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(path, diskPrimary, pTfs, dir, TSDB_FILENAME_LEN); info.config = vnodeCfgDefault; @@ -401,12 +401,12 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC pVnode->pTfs = pTfs; pVnode->diskPrimary = diskPrimary; pVnode->msgCb = msgCb; - taosThreadMutexInit(&pVnode->lock, NULL); + (void)taosThreadMutexInit(&pVnode->lock, NULL); pVnode->blocked = false; tsem_init(&pVnode->syncSem, 0, 0); - taosThreadMutexInit(&pVnode->mutex, NULL); - taosThreadCondInit(&pVnode->poolNotEmpty, NULL); + (void)taosThreadMutexInit(&pVnode->mutex, NULL); + (void)taosThreadCondInit(&pVnode->poolNotEmpty, NULL); if (vnodeAChannelInit(1, &pVnode->commitChannel) != 0) { vError("vgId:%d, failed to init commit channel", TD_VID(pVnode)); @@ -439,7 +439,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC // open wal sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR); - taosRealPath(tdir, NULL, sizeof(tdir)); + (void)taosRealPath(tdir, NULL, sizeof(tdir)); pVnode->pWal = walOpen(tdir, &(pVnode->config.walCfg)); if (pVnode->pWal == NULL) { @@ -449,7 +449,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC // open tq sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR); - taosRealPath(tdir, NULL, sizeof(tdir)); + (void)taosRealPath(tdir, NULL, sizeof(tdir)); // open query if (vnodeQueryOpen(pVnode)) { @@ -502,7 +502,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels); vInfo("vgId:%d, new metric:%p", TD_VID(pVnode), counter); if (taos_collector_registry_register_metric(counter) == 1) { - taos_counter_destroy(counter); + (void)taos_counter_destroy(counter); counter = taos_collector_registry_get_metric(VNODE_METRIC_SQL_COUNT); vInfo("vgId:%d, get metric from registry:%p", TD_VID(pVnode), counter); } @@ -516,10 +516,10 @@ _err: if (pVnode->pQuery) vnodeQueryClose(pVnode); if (pVnode->pTq) tqClose(pVnode->pTq); if (pVnode->pWal) walClose(pVnode->pWal); - if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); - if (pVnode->pSma) smaClose(pVnode->pSma); - if (pVnode->pMeta) metaClose(&pVnode->pMeta); - if (pVnode->freeList) vnodeCloseBufPool(pVnode); + if (pVnode->pTsdb) (void)tsdbClose(&pVnode->pTsdb); + if (pVnode->pSma) (void)smaClose(pVnode->pSma); + if (pVnode->pMeta) (void)metaClose(&pVnode->pMeta); + if (pVnode->freeList) (void)vnodeCloseBufPool(pVnode); taosMemoryFree(pVnode); return NULL; @@ -534,22 +534,22 @@ void vnodePostClose(SVnode *pVnode) { vnodeSyncPostClose(pVnode); } void vnodeClose(SVnode *pVnode) { if (pVnode) { - vnodeAWait(&pVnode->commitTask); - vnodeAChannelDestroy(&pVnode->commitChannel, true); + (void)vnodeAWait(&pVnode->commitTask); + (void)vnodeAChannelDestroy(&pVnode->commitChannel, true); vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); tqClose(pVnode->pTq); walClose(pVnode->pWal); if (pVnode->pTsdb) tsdbClose(&pVnode->pTsdb); - smaClose(pVnode->pSma); + (void)smaClose(pVnode->pSma); if (pVnode->pMeta) metaClose(&pVnode->pMeta); - vnodeCloseBufPool(pVnode); + (void)vnodeCloseBufPool(pVnode); // destroy handle tsem_destroy(&pVnode->syncSem); taosThreadCondDestroy(&pVnode->poolNotEmpty); - taosThreadMutexDestroy(&pVnode->mutex); - taosThreadMutexDestroy(&pVnode->lock); + (void)taosThreadMutexDestroy(&pVnode->mutex); + (void)taosThreadMutexDestroy(&pVnode->lock); taosMemoryFree(pVnode); } } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 6b46ddd8df..36d473fe56 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -709,11 +709,12 @@ const int tkLogStbNum = ARRAY_SIZE(tkLogStb); const int tkAuditStbNum = ARRAY_SIZE(tkAuditStb); // exclude stbs of taoskeeper log -static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) { - int32_t tbSize = 0; +static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode, int32_t *tbSize) { + int32_t code = TSDB_CODE_SUCCESS; int32_t tbNum = 0; const char **pTbArr = NULL; const char *dbName = NULL; + *tbSize = 0; if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0; if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) { @@ -724,19 +725,22 @@ static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) { pTbArr = (const char **)&tkAuditStb; } if (tbNum && pTbArr) { - tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0); - if (tbSize < tbNum) { + *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0); + if (*tbSize < tbNum) { for (int32_t i = 0; i < tbNum; ++i) { tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, pTbArr[i]); if (suid != 0) { - metaPutTbToFilterCache(pVnode->pMeta, &suid, 0); + code = metaPutTbToFilterCache(pVnode->pMeta, &suid, 0); + if (TSDB_CODE_SUCCESS != code) { + return code; + } } } - tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0); + *tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0); } } - return tbSize; + return code; } #endif @@ -758,8 +762,12 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) { } int32_t tbFilterSize = 0; + int32_t code = TSDB_CODE_SUCCESS; #ifdef TD_ENTERPRISE - tbFilterSize = vnodeGetTimeSeriesBlackList(pVnode); + code = vnodeGetTimeSeriesBlackList(pVnode, &tbFilterSize); + if (TSDB_CODE_SUCCESS != code) { + goto _exit; + } #endif if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) || @@ -771,7 +779,6 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) { *num = 0; int64_t arrSize = taosArrayGetSize(suidList); - int32_t code = TSDB_CODE_SUCCESS; for (int64_t i = 0; i < arrSize; ++i) { tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i); diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index f30b2f2ada..d4f987c259 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -209,7 +209,7 @@ static void vnodeSnapReaderDestroyTsdbRanges(SVSnapReader *pReader) { for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) { TFileSetRangeArray **ppRanges = vnodeSnapReaderGetTsdbRanges(pReader, tsdbTyps[j]); if (ppRanges == NULL) continue; - tsdbTFileSetRangeArrayDestroy(ppRanges); + (void)tsdbTFileSetRangeArrayDestroy(ppRanges); } } @@ -218,15 +218,15 @@ void vnodeSnapReaderClose(SVSnapReader *pReader) { vnodeSnapReaderDestroyTsdbRanges(pReader); if (pReader->pRsmaReader) { - rsmaSnapReaderClose(&pReader->pRsmaReader); + (void)rsmaSnapReaderClose(&pReader->pRsmaReader); } if (pReader->pTsdbReader) { - tsdbSnapReaderClose(&pReader->pTsdbReader); + (void)tsdbSnapReaderClose(&pReader->pTsdbReader); } if (pReader->pTsdbRAWReader) { - tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader); + (void)tsdbSnapRAWReaderClose(&pReader->pTsdbRAWReader); } if (pReader->pMetaReader) { @@ -260,7 +260,7 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) char fName[TSDB_FILENAME_LEN]; int32_t offset = 0; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, fName, TSDB_FILENAME_LEN); offset = strlen(fName); snprintf(fName + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, VND_INFO_FNAME); @@ -272,13 +272,13 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) int64_t size; if (taosFStatFile(pFile, &size, NULL) < 0) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size + 1); if (*ppData == NULL) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TSDB_CODE_OUT_OF_MEMORY, lino, _exit); } ((SSnapDataHdr *)(*ppData))->type = SNAP_DATA_CFG; @@ -287,11 +287,11 @@ int32_t vnodeSnapRead(SVSnapReader *pReader, uint8_t **ppData, uint32_t *nData) if (taosReadFile(pFile, ((SSnapDataHdr *)(*ppData))->data, size) < 0) { taosMemoryFree(*ppData); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); TSDB_CHECK_CODE(code = TAOS_SYSTEM_ERROR(errno), lino, _exit); } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); pReader->cfgDone = 1; goto _exit; @@ -590,15 +590,15 @@ extern int32_t tsdbDisableAndCancelAllBgTask(STsdb *pTsdb); extern int32_t tsdbEnableBgTask(STsdb *pTsdb); static int32_t vnodeCancelAndDisableAllBgTask(SVnode *pVnode) { - tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); - vnodeSyncCommit(pVnode); - vnodeAChannelDestroy(&pVnode->commitChannel, true); + (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); + (void)vnodeSyncCommit(pVnode); + (void)vnodeAChannelDestroy(&pVnode->commitChannel, true); return 0; } static int32_t vnodeEnableBgTask(SVnode *pVnode) { - tsdbEnableBgTask(pVnode->pTsdb); - vnodeAChannelInit(1, &pVnode->commitChannel); + (void)tsdbEnableBgTask(pVnode->pTsdb); + (void)vnodeAChannelInit(1, &pVnode->commitChannel); return 0; } @@ -646,7 +646,7 @@ static void vnodeSnapWriterDestroyTsdbRanges(SVSnapWriter *pWriter) { for (int32_t j = 0; j < TSDB_RETENTION_MAX; ++j) { TFileSetRangeArray **ppRanges = vnodeSnapWriterGetTsdbRanges(pWriter, tsdbTyps[j]); if (ppRanges == NULL) continue; - tsdbTFileSetRangeArrayDestroy(ppRanges); + (void)tsdbTFileSetRangeArrayDestroy(ppRanges); } } @@ -658,15 +658,15 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * // prepare if (pWriter->pTsdbSnapWriter) { - tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter); + (void)tsdbSnapWriterPrepareClose(pWriter->pTsdbSnapWriter); } if (pWriter->pTsdbSnapRAWWriter) { - tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter); + (void)tsdbSnapRAWWriterPrepareClose(pWriter->pTsdbSnapRAWWriter); } if (pWriter->pRsmaSnapWriter) { - rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter); + (void)rsmaSnapWriterPrepareClose(pWriter->pRsmaSnapWriter); } // commit json @@ -681,7 +681,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * .applyTerm = pWriter->info.state.commitTerm}; pVnode->statis = pWriter->info.statis; char dir[TSDB_FILENAME_LEN] = {0}; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); code = vnodeCommitInfo(dir); if (code) goto _exit; @@ -740,7 +740,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * if (code) goto _exit; } - vnodeBegin(pVnode); + (void)vnodeBegin(pVnode); _exit: if (code) { @@ -768,7 +768,7 @@ static int32_t vnodeSnapWriteInfo(SVSnapWriter *pWriter, uint8_t *pData, uint32_ // modify info as needed char dir[TSDB_FILENAME_LEN] = {0}; - vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); + (void)vnodeGetPrimaryDir(pVnode->path, pVnode->diskPrimary, pVnode->pTfs, dir, TSDB_FILENAME_LEN); SVnodeStats vndStats = pWriter->info.config.vndStats; pWriter->info.config = pVnode->config; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 1b656442a5..6a73baecae 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -207,7 +207,7 @@ static int32_t vnodePreProcessDropTtlMsg(SVnode *pVnode, SRpcMsg *pMsg) { TSDB_CHECK_CODE(code, lino, _exit); } - tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq); + (void)tSerializeSVDropTtlTableReq((char *)pContNew + sizeof(SMsgHead), reqLenNew, &ttlReq); pContNew->contLen = htonl(reqLenNew); pContNew->vgId = pContOld->vgId; @@ -422,7 +422,7 @@ static int32_t vnodePreProcessDeleteMsg(SVnode *pVnode, SRpcMsg *pMsg) { ((SMsgHead *)pCont)->vgId = TD_VID(pVnode); tEncoderInit(pCoder, pCont + sizeof(SMsgHead), size); - tEncodeDeleteRes(pCoder, &res); + (void)tEncodeDeleteRes(pCoder, &res); tEncoderClear(pCoder); rpcFreeCont(pMsg->pCont); @@ -632,7 +632,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg } break; case TDMT_STREAM_CONSEN_CHKPT: { if (pVnode->restored) { - tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg); + (void)tqProcessTaskConsenChkptIdReq(pVnode->pTq, pMsg); } } break; case TDMT_STREAM_TASK_PAUSE: { @@ -649,7 +649,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg } break; case TDMT_VND_STREAM_TASK_RESET: { if (pVnode->restored && vnodeIsLeader(pVnode)) { - tqProcessTaskResetReq(pVnode->pTq, pMsg); + (void)tqProcessTaskResetReq(pVnode->pTq, pMsg); } } break; case TDMT_VND_ALTER_CONFIRM: @@ -871,7 +871,7 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) } void smaHandleRes(void *pVnode, int64_t smaId, const SArray *data) { - tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); + (void)tdProcessTSmaInsert(((SVnode *)pVnode)->pSma, smaId, (const char *)data); } void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) { @@ -942,7 +942,7 @@ static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq, int ret = 0; if (ttlReq.nUids > 0) { metaDropTables(pVnode->pMeta, ttlReq.pTbUids); - tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false); + (void)tqUpdateTbUidList(pVnode->pTq, ttlReq.pTbUids, false); } end: @@ -1142,7 +1142,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, } } else { cRsp.code = TSDB_CODE_SUCCESS; - tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); + (void)tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid); if (taosArrayPush(tbUids, &pCreateReq->uid) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; rcode = -1; @@ -1159,11 +1159,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, } vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids)); - tqUpdateTbUidList(pVnode->pTq, tbUids, true); + (void)tqUpdateTbUidList(pVnode->pTq, tbUids, true); if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) { goto _exit; } - tdUidStoreFree(pStore); + (void)tdUidStoreFree(pStore); // prepare rsp int32_t ret = 0; @@ -1175,13 +1175,13 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, goto _exit; } tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); - tEncodeSVCreateTbBatchRsp(&encoder, &rsp); + (void)tEncodeSVCreateTbBatchRsp(&encoder, &rsp); if (tsEnableAudit && tsEnableAuditCreateTable) { int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; SName name = {0}; - tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + (void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); SStringBuilder sb = {0}; for (int32_t i = 0; i < tbNames->size; i++) { @@ -1329,7 +1329,7 @@ _exit: tEncodeSize(tEncodeSVAlterTbRsp, &vAlterTbRsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); + (void)tEncodeSVAlterTbRsp(&ec, &vAlterTbRsp); tEncoderClear(&ec); if (vMetaRsp.pSchemas) { taosMemoryFree(vMetaRsp.pSchemas); @@ -1384,7 +1384,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in } } else { dropTbRsp.code = TSDB_CODE_SUCCESS; - if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); + if (tbUid > 0) (void)tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid); } if (taosArrayPush(rsp.pArray, &dropTbRsp) == NULL) { @@ -1404,14 +1404,14 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in } } - tqUpdateTbUidList(pVnode->pTq, tbUids, false); + (void)tqUpdateTbUidList(pVnode->pTq, tbUids, false); tdUpdateTbUidList(pVnode->pSma, pStore, false); if (tsEnableAuditCreateTable) { int64_t clusterId = pVnode->config.syncCfg.nodeInfo[0].clusterId; SName name = {0}; - tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); + (void)tNameFromString(&name, pVnode->config.dbname, T_NAME_ACCT | T_NAME_DB); SStringBuilder sb = {0}; for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { @@ -1435,7 +1435,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in _exit: taosArrayDestroy(tbUids); - tdUidStoreFree(pStore); + (void)tdUidStoreFree(pStore); tDecoderClear(&decoder); tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); @@ -1876,7 +1876,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, in if (taosArrayGetSize(newTbUids) > 0) { vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode), (int32_t)taosArrayGetSize(newTbUids)); - tqUpdateTbUidList(pVnode->pTq, newTbUids, true); + (void)tqUpdateTbUidList(pVnode->pTq, newTbUids, true); } _exit: @@ -1885,13 +1885,13 @@ _exit: tEncodeSize(tEncodeSSubmitRsp2, pSubmitRsp, pRsp->contLen, ret); pRsp->pCont = rpcMallocCont(pRsp->contLen); tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSSubmitRsp2(&ec, pSubmitRsp); + (void)tEncodeSSubmitRsp2(&ec, pSubmitRsp); tEncoderClear(&ec); // update statistics - atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows); - atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows); - atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1); + (void)atomic_add_fetch_64(&pVnode->statis.nInsert, pSubmitRsp->affectedRows); + (void)atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, pSubmitRsp->affectedRows); + (void)atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1); if (tsEnableMonitor && pSubmitRsp->affectedRows > 0 && strlen(pOriginalMsg->info.conn.user) > 0) { const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS, @@ -1901,11 +1901,11 @@ _exit: pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Success"}; - taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels); + (void)taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels); } if (code == 0) { - atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1); + (void)atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1); code = tdProcessRSmaSubmit(pVnode->pSma, ver, pSubmitReq, pReq, len); } /* @@ -2125,10 +2125,10 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe if (req.sttTrigger > 1 && pVnode->config.sttTrigger > 1) { pVnode->config.sttTrigger = req.sttTrigger; } else { - vnodeAWait(&pVnode->commitTask); - tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); + (void)vnodeAWait(&pVnode->commitTask); + (void)tsdbDisableAndCancelAllBgTask(pVnode->pTsdb); pVnode->config.sttTrigger = req.sttTrigger; - tsdbEnableBgTask(pVnode->pTsdb); + (void)tsdbEnableBgTask(pVnode->pTsdb); } } @@ -2144,11 +2144,11 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pRe } if (walChanged) { - walAlter(pVnode->pWal, &pVnode->config.walCfg); + (void)walAlter(pVnode->pWal, &pVnode->config.walCfg); } if (tsdbChanged) { - tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg); + (void)tsdbSetKeepCfg(pVnode->pTsdb, &pVnode->config.tsdbCfg); } return 0; @@ -2220,7 +2220,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in } tDecoderInit(pCoder, pReq, len); - tDecodeDeleteRes(pCoder, pRes); + code = tDecodeDeleteRes(pCoder, pRes); + if (code) goto _err; if (pRes->affectedRows > 0) { for (int32_t iUid = 0; iUid < taosArrayGetSize(pRes->uidList); iUid++) { @@ -2243,7 +2244,8 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in pRsp->pCont = rpcMallocCont(pRsp->contLen); SEncoder ec = {0}; tEncoderInit(&ec, pRsp->pCont, pRsp->contLen); - tEncodeSVDeleteRsp(&ec, &rsp); + code = tEncodeSVDeleteRsp(&ec, &rsp); + if (code) goto _err; tEncoderClear(&ec); return code; @@ -2325,7 +2327,7 @@ static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pR } static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { - syncCheckMember(pVnode->sync); + (void)syncCheckMember(pVnode->sync); pRsp->msgType = TDMT_SYNC_CONFIG_CHANGE_RSP; pRsp->code = TSDB_CODE_SUCCESS; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 742d7e4f3f..9fcb765c50 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -28,22 +28,22 @@ static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { const STraceId *trace = &pMsg->info.traceId; vGTrace("vgId:%d, msg:%p wait block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq); - tsem_wait(&pVnode->syncSem); + (void)tsem_wait(&pVnode->syncSem); } static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { if (vnodeIsMsgBlock(pMsg->msgType)) { const STraceId *trace = &pMsg->info.traceId; - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { vGTrace("vgId:%d, msg:%p post block, type:%s sec:%d seq:%" PRId64, pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType), pVnode->blockSec, pVnode->blockSeq); pVnode->blocked = false; pVnode->blockSec = 0; pVnode->blockSeq = 0; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); } } @@ -69,7 +69,7 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) { if (rsp.pCont == NULL) { pMsg->code = TSDB_CODE_OUT_OF_MEMORY; } else { - tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); + (void)tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); rsp.contLen = contLen; } @@ -113,7 +113,7 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) { int64_t seq = 0; - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); int32_t code = syncPropose(pVnode->sync, pMsg, isWeak, &seq); bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType)); if (wait) { @@ -122,7 +122,7 @@ static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak pVnode->blockSec = taosGetTimestampSec(); pVnode->blockSeq = seq; } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); if (code > 0) { vnodeHandleWriteMsg(pVnode, pMsg); @@ -161,7 +161,7 @@ void vnodeProposeCommitOnNeed(SVnode *pVnode, bool atExit) { rpcFreeCont(rpcMsg.pCont); rpcMsg.pCont = NULL; } else { - tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg); + (void)tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &rpcMsg); } } @@ -171,14 +171,14 @@ static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool if (*arrSize <= 0) return; SRpcMsg *pLastMsg = pMsgArr[*arrSize - 1]; - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize); bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType)); if (wait) { ASSERT(!pVnode->blocked); pVnode->blocked = true; } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); if (code > 0) { for (int32_t i = 0; i < *arrSize; ++i) { @@ -556,7 +556,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) } while (true); ASSERT(commitIdx == vnodeSyncAppliedIndex(pFsm)); - walApplyVer(pVnode->pWal, commitIdx); + (void)walApplyVer(pVnode->pWal, commitIdx); pVnode->restored = true; SStreamMeta *pMeta = pVnode->pTq->pStreamMeta; @@ -598,17 +598,17 @@ static void vnodeBecomeFollower(const SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; vInfo("vgId:%d, become follower", pVnode->config.vgId); - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { pVnode->blocked = false; vDebug("vgId:%d, become follower and post block", pVnode->config.vgId); - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); if (pVnode->pTq) { tqUpdateNodeStage(pVnode->pTq, false); - tqStopStreamTasksAsync(pVnode->pTq); + (void)tqStopStreamTasksAsync(pVnode->pTq); } } @@ -616,13 +616,13 @@ static void vnodeBecomeLearner(const SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; vInfo("vgId:%d, become learner", pVnode->config.vgId); - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { pVnode->blocked = false; vDebug("vgId:%d, become learner and post block", pVnode->config.vgId); - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); } static void vnodeBecomeLeader(const SSyncFSM *pFsm) { @@ -743,16 +743,16 @@ int32_t vnodeSyncStart(SVnode *pVnode) { void vnodeSyncPreClose(SVnode *pVnode) { vInfo("vgId:%d, sync pre close", pVnode->config.vgId); - syncLeaderTransfer(pVnode->sync); + (void)syncLeaderTransfer(pVnode->sync); syncPreStop(pVnode->sync); - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { vInfo("vgId:%d, post block after close sync", pVnode->config.vgId); pVnode->blocked = false; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); } void vnodeSyncPostClose(SVnode *pVnode) { @@ -767,7 +767,7 @@ void vnodeSyncClose(SVnode *pVnode) { void vnodeSyncCheckTimeout(SVnode *pVnode) { vTrace("vgId:%d, check sync timeout msg", pVnode->config.vgId); - taosThreadMutexLock(&pVnode->lock); + (void)taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { int32_t curSec = taosGetTimestampSec(); int32_t delta = curSec - pVnode->blockSec; @@ -785,10 +785,10 @@ void vnodeSyncCheckTimeout(SVnode *pVnode) { pVnode->blocked = false; pVnode->blockSec = 0; pVnode->blockSeq = 0; - tsem_post(&pVnode->syncSem); + (void)tsem_post(&pVnode->syncSem); } } - taosThreadMutexUnlock(&pVnode->lock); + (void)taosThreadMutexUnlock(&pVnode->lock); } bool vnodeIsRoleLeader(SVnode *pVnode) { diff --git a/source/libs/executor/src/dynqueryctrloperator.c b/source/libs/executor/src/dynqueryctrloperator.c index 3b025685dc..5359cc0980 100644 --- a/source/libs/executor/src/dynqueryctrloperator.c +++ b/source/libs/executor/src/dynqueryctrloperator.c @@ -248,7 +248,11 @@ static int32_t buildExchangeOperatorParam(SOperatorParam** ppRes, int32_t downst taosMemoryFree(pExc); return terrno; } - taosArrayPush(pExc->basic.uidList, pUid); + if (NULL == taosArrayPush(pExc->basic.uidList, pUid)) { + taosArrayDestroy(pExc->basic.uidList); + taosMemoryFree(pExc); + return terrno; + } (*ppRes)->opType = QUERY_NODE_PHYSICAL_PLAN_EXCHANGE; (*ppRes)->downstreamIdx = downstreamIdx; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index bd82d8114d..75c335a6a8 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -1160,7 +1160,13 @@ SMqBatchMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - return tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset); + tOffsetCopy(pOffset, &pTaskInfo->streamInfo.currentOffset); + return 0; + /*if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + pTaskInfo->code = code; + T_LONG_JMP(pTaskInfo->env, code); + }*/ } int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* sContext, SMetaTableInfo* pMtInfo) { diff --git a/source/libs/executor/src/executorInt.c b/source/libs/executor/src/executorInt.c index 2f87cd7fc1..bceefd2c0d 100644 --- a/source/libs/executor/src/executorInt.c +++ b/source/libs/executor/src/executorInt.c @@ -75,7 +75,7 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { static int32_t setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static int32_t initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); +static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol); @@ -193,7 +193,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR // add a new result set for a new group SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; int32_t code = tSimpleHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, - sizeof(SResultRowPosition)); + sizeof(SResultRowPosition)); if (code != TSDB_CODE_SUCCESS) { qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); T_LONG_JMP(pTaskInfo->env, code); @@ -522,7 +522,7 @@ int32_t setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t n if (!pResInfo->initialized) { if (pCtx[i].functionId != -1) { int32_t code = pCtx[i].fpSet.init(&pCtx[i], pResInfo); - if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)){ + if (code != TSDB_CODE_SUCCESS && fmIsUserDefinedFunc(pCtx[i].functionId)) { pResInfo->initialized = false; return TSDB_CODE_UDF_FUNC_EXEC_FAILURE; } @@ -593,7 +593,7 @@ _err: } int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, int32_t status) { - int32_t code = 0; + int32_t code = TSDB_CODE_SUCCESS; int8_t* pIndicator = (int8_t*)p->pData; if (status == FILTER_RESULT_ALL_QUALIFIED) { // here nothing needs to be done @@ -605,7 +605,6 @@ int32_t extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnIn } else { qError("unknown filter result type: %d", status); } - return code; } @@ -643,7 +642,7 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset); if (pCtx[j].fpSet.finalize) { if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 || - strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) { + strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) { // for groupkey along with functions that output multiple lines(e.g. Histogram) // need to match groupkey result for each output row of that function. if (pCtx[j].resultInfo->numOfRes != 0) { @@ -682,7 +681,7 @@ _end: // todo refactor. SResultRow has direct pointer in miainfo void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup, - SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { + SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { SFilePage* page = getBufPage(pBuf, resultRowPosition->pageId); if (page == NULL) { qError("failed to get buffer, code:%s, %s", tstrerror(terrno), GET_TASKID(pTaskInfo)); @@ -698,7 +697,7 @@ void finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPositi doUpdateNumOfRows(pCtx, pRow, pSup->numOfExprs, rowEntryOffset); if (pRow->numOfRows == 0) { releaseBufPage(pBuf, page); - return ; + return; } int32_t size = pBlock->info.capacity; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 6755f131b6..acc3de3447 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1311,7 +1311,8 @@ static void destroyTableScanOperatorInfo(void* param) { } int32_t createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, + SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -1404,7 +1405,7 @@ _error: int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); - int32_t code = 0; + int32_t code = 0; STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -1422,7 +1423,7 @@ int32_t createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pTaskIn *pOptrInfo = pOperator; return code; - _end: +_end: if (pInfo != NULL) { taosMemoryFree(pInfo); } @@ -2413,10 +2414,14 @@ _end: return code; } -static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) { +static int32_t doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeWindow* pWindow, const char* id) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; + bool* p = NULL; if (pWindow->skey != INT64_MIN || pWindow->ekey != INT64_MAX) { - bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); - bool hasUnqualified = false; + p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, tsIndex); @@ -2445,19 +2450,28 @@ static void doBlockDataWindowFilter(SSDataBlock* pBlock, int32_t tsIndex, STimeW } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); + QUERY_CHECK_CODE(code, lino, _end); } - - taosMemoryFree(p); } + +_end: + taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } -static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) { +static int32_t doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offset) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; if (pBlock->info.window.skey != offset->ts || offset->primaryKey.type == 0) { - return; + return code; } bool* p = taosMemoryCalloc(pBlock->info.rows, sizeof(bool)); - bool hasUnqualified = false; + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; SColumnInfoData* pColTs = taosArrayGet(pBlock->pDataBlock, 0); SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1); @@ -2485,16 +2499,26 @@ static void doBlockDataPrimaryKeyFilter(SSDataBlock* pBlock, STqOffsetVal* offse } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); + QUERY_CHECK_CODE(code, lino, _end); } +_end: taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } // re-build the delete block, ONLY according to the split timestamp -static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) { +static int32_t rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, const char* id) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t lino = 0; int32_t numOfRows = pBlock->info.rows; bool* p = taosMemoryCalloc(numOfRows, sizeof(bool)); + QUERY_CHECK_NULL(p, code, lino, _end, terrno); + bool hasUnqualified = false; int64_t skey = pWindow->skey; int64_t ekey = pWindow->ekey; @@ -2531,14 +2555,20 @@ static void rebuildDeleteBlockData(SSDataBlock* pBlock, STimeWindow* pWindow, co } if (hasUnqualified) { - trimDataBlock(pBlock, pBlock->info.rows, p); + code = trimDataBlock(pBlock, pBlock->info.rows, p); qDebug("%s re-build delete datablock, start key revised to:%" PRId64 ", rows:%" PRId64, id, skey, pBlock->info.rows); + QUERY_CHECK_CODE(code, lino, _end); } else { qDebug("%s not update the delete block", id); } +_end: taosMemoryFree(p); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); + } + return code; } static int32_t colIdComparFn(const void* param1, const void* param2) { @@ -2657,7 +2687,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock } // filter the block extracted from WAL files, according to the time window apply additional time window filter - doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id); + code = doBlockDataWindowFilter(pInfo->pRes, pInfo->primaryTsIndex, pTimeWindow, id); + QUERY_CHECK_CODE(code, lino, _end); pInfo->pRes->info.dataLoad = 1; code = blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); @@ -2676,14 +2707,19 @@ _end: return code; } -static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) { - SValue val = {0}; +static int32_t processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffsetVal* offset) { + int32_t code = TSDB_CODE_SUCCESS; + SValue val = {0}; if (hasPrimaryKey) { - doBlockDataPrimaryKeyFilter(pBlock, offset); + code = doBlockDataPrimaryKeyFilter(pBlock, offset); + if (code != TSDB_CODE_SUCCESS) { + qError("%s failed at line %d since %s", __func__, __LINE__, tstrerror(code)); + return code; + } SColumnInfoData* pColPk = taosArrayGet(pBlock->pDataBlock, 1); if (pBlock->info.rows < 1) { - return; + return code; } void* tmp = colDataGetData(pColPk, pBlock->info.rows - 1); val.type = pColPk->info.type; @@ -2696,6 +2732,7 @@ static void processPrimaryKey(SSDataBlock* pBlock, bool hasPrimaryKey, STqOffset } } tqOffsetResetToData(offset, pBlock->info.id.uid, pBlock->info.window.ekey, val); + return code; } static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { @@ -2711,7 +2748,7 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (isTaskKilled(pTaskInfo)) { (*ppRes) = NULL; - return code; + return pTaskInfo->code; } if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__SNAPSHOT_DATA) { @@ -2720,9 +2757,9 @@ static int32_t doQueueScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (pResult && pResult->info.rows > 0) { bool hasPrimaryKey = pAPI->tqReaderFn.tqGetTablePrimaryKey(pInfo->tqReader); - processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); - qDebug("tmqsnap doQueueScan get data uid:%" PRId64 "", pResult->info.id.uid); - if (pResult->info.rows > 0) { + code = processPrimaryKey(pResult, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); + qDebug("tmqsnap doQueueScan get data utid:%" PRId64 "", pResult->info.id.uid); + if (pResult->info.rows > 0 || code != TSDB_CODE_SUCCESS) { (*ppRes) = pResult; return code; } @@ -3156,7 +3193,8 @@ FETCH_NEXT_BLOCK: code = setBlockGroupIdByUid(pInfo, pDelBlock); QUERY_CHECK_CODE(code, lino, _end); - rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id); + code = rebuildDeleteBlockData(pDelBlock, &pStreamInfo->fillHistoryWindow, id); + QUERY_CHECK_CODE(code, lino, _end); printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete recv filtered", GET_TASKID(pTaskInfo)); if (pDelBlock->info.rows == 0) { @@ -3479,7 +3517,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { if (pBlock && pBlock->info.rows > 0) { bool hasPrimaryKey = pAPI->snapshotFn.taosXGetTablePrimaryKey(pInfo->sContext); - processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); + code = processPrimaryKey(pBlock, hasPrimaryKey, &pTaskInfo->streamInfo.currentOffset); qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.id.uid); (*ppRes) = pBlock; return code; @@ -3493,7 +3531,7 @@ static int32_t doRawScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { tDeleteSchemaWrapper(mtInfo.schema); goto _end; } - STqOffsetVal offset = {0}; + STqOffsetVal offset = {0}; if (mtInfo.uid == 0 || pInfo->sContext->withMeta == ONLY_META) { // read snapshot done, change to get data from wal qDebug("tmqsnap read snapshot done, change to get data from wal"); tqOffsetResetToLog(&offset, pInfo->sContext->snapVersion + 1); @@ -3964,7 +4002,7 @@ int32_t createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* QUERY_CHECK_CODE(code, lino, _error); pInfo->updateWin = (STimeWindow){.skey = INT64_MAX, .ekey = INT64_MAX}; - createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes); + code = createSpecialDataBlock(STREAM_CLEAR, &pInfo->pUpdateDataRes); QUERY_CHECK_CODE(code, lino, _error); if (hasPrimaryKeyCol(pInfo)) { @@ -4123,7 +4161,7 @@ static EDealRes tagScanRewriteTagColumn(SNode** pNode, void* pContext) { int32_t code = TSDB_CODE_SUCCESS; int32_t lino = 0; STagScanFilterContext* pCtx = (STagScanFilterContext*)pContext; - SColumnNode* pSColumnNode = NULL; + SColumnNode* pSColumnNode = NULL; if (QUERY_NODE_COLUMN == nodeType((*pNode))) { pSColumnNode = *(SColumnNode**)pNode; } else if (QUERY_NODE_FUNCTION == nodeType((*pNode))) { @@ -4484,8 +4522,8 @@ static void destroyTagScanOperatorInfo(void* param) { } int32_t createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pTagScanNode, - STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, - SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, + SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -5083,7 +5121,7 @@ _end: static SSDataBlock* doTableMergeScanParaSubTables(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes); + int32_t code = doTableMergeScanParaSubTablesNext(pOperator, &pRes); return pRes; } @@ -5317,7 +5355,7 @@ int32_t startDurationForGroupTableMergeScan(SOperatorInfo* pOperator) { pInfo->pSortHandle = NULL; code = tsortCreateSortHandle(pInfo->pSortInfo, SORT_BLOCK_TS_MERGE, pInfo->bufPageSize, numOfBufPage, - pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle); + pInfo->pSortInputBlock, pTaskInfo->id.str, 0, 0, 0, &pInfo->pSortHandle); if (code) { return code; } @@ -5569,7 +5607,7 @@ _end: static SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableMergeScanNext(pOperator, &pRes); + int32_t code = doTableMergeScanNext(pOperator, &pRes); return pRes; } @@ -5626,10 +5664,11 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla } int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo, + SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); - int32_t code = 0; + int32_t code = 0; STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -5641,7 +5680,7 @@ int32_t createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SR int32_t numOfCols = 0; code = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, - &pInfo->base.matchInfo); + &pInfo->base.matchInfo); int32_t lino = 0; if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -5867,7 +5906,7 @@ int32_t getTableCountScanSupp(SNodeList* groupTags, SName* tableName, SNodeList* } int32_t createTableCountScanOperatorInfo(SReadHandle* readHandle, STableCountScanPhysiNode* pTblCountScanNode, - SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { + SExecTaskInfo* pTaskInfo, SOperatorInfo** pOptrInfo) { QRY_OPTR_CHECK(pOptrInfo); int32_t code = TSDB_CODE_SUCCESS; @@ -6040,7 +6079,7 @@ _end: } static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STableCountScanOperatorInfo* pInfo = pOperator->info; STableCountScanSupp* pSupp = &pInfo->supp; @@ -6062,7 +6101,7 @@ static int32_t doTableCountScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRe static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = NULL; - int32_t code = doTableCountScanNext(pOperator, &pRes); + int32_t code = doTableCountScanNext(pOperator, &pRes); return pRes; } diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 76eaccb4ec..17ef2fe41f 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -510,18 +510,16 @@ int32_t doStreamEventDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOpera int32_t mapSize = 0; buf = taosDecodeFixedI32(buf, &mapSize); for (int32_t i = 0; i < mapSize; i++) { - SSessionKey key = {0}; SResultWindowInfo winfo = {0}; - buf = decodeSSessionKey(buf, &key); + buf = decodeSSessionKey(buf, &winfo.sessionWin); int32_t winCode = TSDB_CODE_SUCCESS; code = pAggSup->stateStore.streamStateSessionAddIfNotExist( pAggSup->pState, &winfo.sessionWin, pAggSup->gap, (void**)&winfo.pStatePos, &pAggSup->resultRowSize, &winCode); QUERY_CHECK_CODE(code, lino, _end); - ASSERT(winCode == TSDB_CODE_SUCCESS); buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize); code = - tSimpleHashPut(pInfo->streamAggSup.pResultRows, &key, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo)); + tSimpleHashPut(pInfo->streamAggSup.pResultRows, &winfo.sessionWin, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo)); QUERY_CHECK_CODE(code, lino, _end); } diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index aebc2d9c97..7462d71a8a 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -5183,7 +5183,7 @@ int32_t createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); pInfo->delIndex = 0; - createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes); + code = createSpecialDataBlock(STREAM_DELETE_RESULT, &pInfo->pDelRes); QUERY_CHECK_CODE(code, lino, _error); initResultRowInfo(&pInfo->binfo.resultRowInfo); diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 59cfd85bc3..83b2d35aef 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2229,7 +2229,10 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) { double v = 0; // value int64_t w = 1; // weigth GET_TYPED_DATA(v, double, type, data); - tdigestAdd(pInfo->pTDigest, v, w); + int32_t code = tdigestAdd(pInfo->pTDigest, v, w); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } else { // might be a race condition here that pHisto can be overwritten or setup function @@ -2285,7 +2288,10 @@ static int32_t apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInf (void)memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION)); tdigestAutoFill(pTDigest, COMPRESSION); } else { - tdigestMerge(pTDigest, pInput->pTDigest); + int32_t code = tdigestMerge(pTDigest, pInput->pTDigest); + if (TSDB_CODE_SUCCESS != code) { + return code; + } } } else { buildHistogramInfo(pInput); diff --git a/source/libs/monitor/src/monMain.c b/source/libs/monitor/src/monMain.c index 6cba9b0727..6bc3c43d0f 100644 --- a/source/libs/monitor/src/monMain.c +++ b/source/libs/monitor/src/monMain.c @@ -28,7 +28,7 @@ char *tsMonSlowLogUri = "/slow-sql-detail-batch"; char *tsMonFwBasicUri = "/taosd-cluster-basic"; void monRecordLog(int64_t ts, ELogLevel level, const char *content) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); int32_t size = taosArrayGetSize(tsMonitor.logs); if (size < tsMonitor.cfg.maxLogs) { SMonLogItem item = {.ts = ts, .level = level}; @@ -37,11 +37,11 @@ void monRecordLog(int64_t ts, ELogLevel level, const char *content) { tstrncpy(pItem->content, content, MON_LOG_LEN); } } - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); } int32_t monGetLogs(SMonLogs *logs) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); logs->logs = taosArrayDup(tsMonitor.logs, NULL); logs->numOfInfoLogs = tsNumOfInfoLogs; logs->numOfErrorLogs = tsNumOfErrorLogs; @@ -52,7 +52,7 @@ int32_t monGetLogs(SMonLogs *logs) { tsNumOfDebugLogs = 0; tsNumOfTraceLogs = 0; taosArrayClear(tsMonitor.logs); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); if (logs->logs == NULL) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } @@ -60,44 +60,44 @@ int32_t monGetLogs(SMonLogs *logs) { } void monSetDmInfo(SMonDmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.dmInfo, pInfo, sizeof(SMonDmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonDmInfo)); } void monSetMmInfo(SMonMmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.mmInfo, pInfo, sizeof(SMonMmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonMmInfo)); } void monSetVmInfo(SMonVmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.vmInfo, pInfo, sizeof(SMonVmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonVmInfo)); } void monSetQmInfo(SMonQmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.qmInfo, pInfo, sizeof(SMonQmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonQmInfo)); } void monSetSmInfo(SMonSmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.smInfo, pInfo, sizeof(SMonSmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonSmInfo)); } void monSetBmInfo(SMonBmInfo *pInfo) { - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&tsMonitor.bmInfo, pInfo, sizeof(SMonBmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); memset(pInfo, 0, sizeof(SMonBmInfo)); } @@ -153,7 +153,7 @@ static SMonInfo *monCreateMonitorInfo() { monGetLogs(&pMonitor->log); - taosThreadMutexLock(&tsMonitor.lock); + (void)taosThreadMutexLock(&tsMonitor.lock); memcpy(&pMonitor->dmInfo, &tsMonitor.dmInfo, sizeof(SMonDmInfo)); memcpy(&pMonitor->mmInfo, &tsMonitor.mmInfo, sizeof(SMonMmInfo)); memcpy(&pMonitor->vmInfo, &tsMonitor.vmInfo, sizeof(SMonVmInfo)); @@ -166,7 +166,7 @@ static SMonInfo *monCreateMonitorInfo() { memset(&tsMonitor.smInfo, 0, sizeof(SMonSmInfo)); memset(&tsMonitor.qmInfo, 0, sizeof(SMonQmInfo)); memset(&tsMonitor.bmInfo, 0, sizeof(SMonBmInfo)); - taosThreadMutexUnlock(&tsMonitor.lock); + (void)taosThreadMutexUnlock(&tsMonitor.lock); pMonitor->pJson = tjsonCreateObject(); if (pMonitor->pJson == NULL || pMonitor->log.logs == NULL) { diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index ffead946ce..025459a8c9 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -533,6 +533,10 @@ int32_t qResetStmtColumns(SArray* pCols, bool deepClear) { for (int32_t i = 0; i < colNum; ++i) { SColData* pCol = (SColData*)taosArrayGet(pCols, i); + if (pCol == NULL){ + qError("qResetStmtColumns column is NULL"); + return TSDB_CODE_OUT_OF_MEMORY; + } if (deepClear) { tColDataDeepClear(pCol); } else { @@ -549,6 +553,10 @@ int32_t qResetStmtDataBlock(STableDataCxt* block, bool deepClear) { for (int32_t i = 0; i < colNum; ++i) { SColData* pCol = (SColData*)taosArrayGet(pBlock->pData->aCol, i); + if (pCol == NULL){ + qError("qResetStmtDataBlock column is NULL"); + return TSDB_CODE_OUT_OF_MEMORY; + } if (deepClear) { tColDataDeepClear(pCol); } else { diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 3d344a8a20..bce8cda125 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -128,7 +128,7 @@ static STaskQueue taskQueue = {0}; static void processTaskQueue(SQueueInfo *pInfo, SSchedMsg *pSchedMsg) { __async_exec_fn_t execFn = (__async_exec_fn_t)pSchedMsg->ahandle; - execFn(pSchedMsg->thandle); + (void)execFn(pSchedMsg->thandle); taosFreeQitem(pSchedMsg); } diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 29dba30669..5226668f82 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1840,8 +1840,8 @@ int32_t filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t optio if (unit->compare.optr2) { (void)strcat(str, " && "); if (unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS) { - sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, - operatorTypeStr(unit->compare.optr2)); + (void)sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, + operatorTypeStr(unit->compare.optr2)); } if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index fd747ce78a..3e5471700c 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -329,10 +329,10 @@ static void tltrim(char *input, char *output, int32_t type, int32_t charLen) { int32_t resLen; if (type == TSDB_DATA_TYPE_VARCHAR) { resLen = charLen - numOfSpaces; - memcpy(varDataVal(output), varDataVal(input) + numOfSpaces, resLen); + (void)memcpy(varDataVal(output), varDataVal(input) + numOfSpaces, resLen); } else { resLen = (charLen - numOfSpaces) * TSDB_NCHAR_SIZE; - memcpy(varDataVal(output), varDataVal(input) + numOfSpaces * TSDB_NCHAR_SIZE, resLen); + (void)memcpy(varDataVal(output), varDataVal(input) + numOfSpaces * TSDB_NCHAR_SIZE, resLen); } varDataSetLen(output, resLen); @@ -362,7 +362,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) { } else { resLen = (charLen - numOfSpaces) * TSDB_NCHAR_SIZE; } - memcpy(varDataVal(output), varDataVal(input), resLen); + (void)memcpy(varDataVal(output), varDataVal(input), resLen); varDataSetLen(output, resLen); } @@ -401,11 +401,11 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, taosMemoryFree(newBuf); return TSDB_CODE_SCALAR_CONVERT_ERROR; } - memcpy(varDataVal(output) + *dataLen, newBuf, varDataLen(input) * TSDB_NCHAR_SIZE); + (void)memcpy(varDataVal(output) + *dataLen, newBuf, varDataLen(input) * TSDB_NCHAR_SIZE); *dataLen += varDataLen(input) * TSDB_NCHAR_SIZE; taosMemoryFree(newBuf); } else { - memcpy(varDataVal(output) + *dataLen, varDataVal(input), varDataLen(input)); + (void)memcpy(varDataVal(output) + *dataLen, varDataVal(input), varDataLen(input)); *dataLen += varDataLen(input); } return TSDB_CODE_SUCCESS; @@ -581,7 +581,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p if (hasNull) { colDataSetNULL(pOutputData, k); - memset(output, 0, dataLen); + (void)memset(output, 0, dataLen); } else { varDataSetLen(output, dataLen); SCL_ERR_JRET(colDataSetVal(pOutputData, k, output, false)); @@ -725,7 +725,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu char *output = outputBuf; int32_t resLen = TMIN(subLen, len - startPosBytes); if (resLen > 0) { - memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen); + (void)memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen); varDataSetLen(output, resLen); } else { varDataSetLen(output, 0); @@ -768,7 +768,7 @@ int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutpu } } char *output = pOutputBuf; - memcpy(varDataVal(output), varDataVal(input), varDataLen(input)); + (void)memcpy(varDataVal(output), varDataVal(input), varDataLen(input)); int32_t len = taosCreateMD5Hash(varDataVal(output), varDataLen(input)); varDataSetLen(output, len); int32_t code = colDataSetVal(pOutputData, i, output, false); @@ -812,7 +812,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp switch (outputType) { case TSDB_DATA_TYPE_TINYINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(int8_t *)output = taosStr2Int8(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -831,7 +831,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_SMALLINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(int16_t *)output = taosStr2Int16(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -849,7 +849,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_INT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(int32_t *)output = taosStr2Int32(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -868,7 +868,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_BIGINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(int64_t *)output = taosStr2Int64(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -886,7 +886,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_UTINYINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(uint8_t *)output = taosStr2UInt8(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -904,7 +904,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_USMALLINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(uint16_t *)output = taosStr2UInt16(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -922,7 +922,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_UINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(uint32_t *)output = taosStr2UInt32(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -940,7 +940,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_UBIGINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(uint64_t *)output = taosStr2UInt64(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -959,7 +959,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_FLOAT: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(float *)output = taosStr2Float(buf, NULL); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -977,7 +977,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_DOUBLE: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(double *)output = taosStr2Double(buf, NULL); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -995,7 +995,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp } case TSDB_DATA_TYPE_BOOL: { if (inputType == TSDB_DATA_TYPE_BINARY) { - memcpy(buf, varDataVal(input), varDataLen(input)); + (void)memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(bool *)output = taosStr2Int8(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { @@ -1036,7 +1036,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_BINARY) { int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE); - memcpy(varDataVal(output), varDataVal(input), len); + (void)memcpy(varDataVal(output), varDataVal(input), len); varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); @@ -1045,13 +1045,13 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp goto _end; } len = TMIN(len, outputLen - VARSTR_HEADER_SIZE); - memcpy(varDataVal(output), convBuf, len); + (void)memcpy(varDataVal(output), convBuf, len); varDataSetLen(output, len); } else { NUM_TO_STRING(inputType, input, bufSize, buf); int32_t len = (int32_t)strlen(buf); len = (outputLen - VARSTR_HEADER_SIZE) > len ? len : (outputLen - VARSTR_HEADER_SIZE); - memcpy(varDataVal(output), buf, len); + (void)memcpy(varDataVal(output), buf, len); varDataSetLen(output, len); } break; @@ -1059,7 +1059,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp case TSDB_DATA_TYPE_VARBINARY:{ if (inputType == TSDB_DATA_TYPE_BINARY) { int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE); - memcpy(varDataVal(output), varDataVal(input), len); + (void)memcpy(varDataVal(output), varDataVal(input), len); varDataSetLen(output, len); }else{ code = TSDB_CODE_FUNC_FUNTION_PARA_TYPE; @@ -1091,7 +1091,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { len = TMIN(outputLen - VARSTR_HEADER_SIZE, varDataLen(input)); - memcpy(output, input, len + VARSTR_HEADER_SIZE); + (void)memcpy(output, input, len + VARSTR_HEADER_SIZE); varDataSetLen(output, len); } else { NUM_TO_STRING(inputType, input, bufSize, buf); @@ -1141,7 +1141,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * int32_t tzLen = 0; if (tzPresent) { tzLen = varDataLen(pInput[1].columnData->pData); - memcpy(tz, varDataVal(pInput[1].columnData->pData), tzLen); + (void)memcpy(tz, varDataVal(pInput[1].columnData->pData), tzLen); } for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { @@ -1218,7 +1218,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * // add timezone string if (tzLen > 0) { - snprintf(buf + len, tzLen + 1, "%s", tz); + (void)snprintf(buf + len, tzLen + 1, "%s", tz); len += tzLen; } @@ -1286,7 +1286,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu taosArrayDestroy(pTagVals); return TSDB_CODE_FAILED; } - memcpy(tmp, varDataVal(input), varDataLen(input)); + (void)memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; if (parseJsontoTagData(tmp, pTagVals, &pTag, NULL)) { code = tTagNew(pTagVals, 1, true, &pTag); @@ -1402,7 +1402,7 @@ _return: int64_t offsetFromTz(char *timezone, int64_t factor) { char *minStr = &timezone[3]; int64_t minutes = taosStr2Int64(minStr, NULL, 10); - memset(minStr, 0, strlen(minStr)); + (void)memset(minStr, 0, strlen(minStr)); int64_t hours = taosStr2Int64(timezone, NULL, 10); int64_t seconds = hours * 3600 + minutes * 60; diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 2109d8d0d6..75180c0b66 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -49,7 +49,7 @@ #define _DEBUG_PRINT_ 0 #if _DEBUG_PRINT_ -#define PRINTF(...) printf(__VA_ARGS__) +#define PRINTF(...) (void)printf(__VA_ARGS__) #else #define PRINTF(...) #endif @@ -84,7 +84,7 @@ void scltInitLogFile() { (void)strcpy(tsLogDir, TD_LOG_DIR_PATH); if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { - printf("failed to open log file in directory:%s\n", tsLogDir); + (void)printf("failed to open log file in directory:%s\n", tsLogDir); } } @@ -1450,7 +1450,7 @@ TEST(columnTest, json_column_arith_op) { OP_TYPE_REM, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR}; int32_t input[len] = {1, 8, 2, 2, 3, 0, -4, 9}; - printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); + (void)printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); char *key = "k1"; double eRes00[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4 & -4, 4 | 9}; double eRes01[len] = {5.0, 4, 8.0, 0.5, 3, 0, 4 & -4, 4 | 9}; @@ -1463,7 +1463,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); + (void)printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); key = "k2"; double eRes10[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; @@ -1477,7 +1477,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); + (void)printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); key = "k3"; double eRes20[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; @@ -1491,7 +1491,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); + (void)printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); key = "k4"; double eRes30[len] = {2.0, -7, 2, 0.5, 1, -1, 1 & -4, 1 | 9}; @@ -1505,7 +1505,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k5"; double eRes40[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5 & -4, 5 | 9}; @@ -1519,7 +1519,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k6"; double eRes50[len] = {-9, -18, -20, -5, -10 % 3, 10, -10 & -4, -10 | 9}; @@ -1533,7 +1533,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k7"; double eRes60[len] = {-8.8, -17.8, -19.6, -4.9, -0.8, 9.8, -9 & -4, -9 | 9}; @@ -1547,7 +1547,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k8"; double eRes70[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; @@ -1561,7 +1561,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k9"; double eRes80[len] = {9, 0, 16, 4, 8 % 3, -8, 8 & -4, 8 | 9}; @@ -1575,7 +1575,7 @@ TEST(columnTest, json_column_arith_op) { ASSERT_EQ(code, TSDB_CODE_SUCCESS); } - printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + (void)printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); key = "k10"; double eRes90[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; @@ -1628,7 +1628,7 @@ TEST(columnTest, json_column_logic_op) { int32_t input[len] = {1, 8, 2, 2, 3, 0, 0, 0, 0}; char *inputNchar[len1] = {"hell_", "hel%", "hell", "llll"}; - printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + (void)printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); char *key = "k1"; bool eRes[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; for (int i = 0; i < len; i++) { @@ -1647,7 +1647,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k2"; bool eRes1[len + len1] = {false, false, false, false, false, false, false, true, false, true, false, true, true}; @@ -1668,7 +1668,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + (void)printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); key = "k3"; // (null is true) return NULL, so use DBL_MAX represent NULL bool eRes2[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; @@ -1689,7 +1689,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k4"; bool eRes3[len + len1] = {false, false, false, false, false, false, false, true, true, false, false, false, false}; @@ -1710,7 +1710,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k5"; bool eRes4[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; @@ -1731,7 +1731,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k6"; bool eRes5[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; @@ -1752,7 +1752,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k7"; bool eRes6[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; @@ -1773,7 +1773,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k8"; bool eRes7[len + len1] = {false, false, false, false, false, false, false, true, false, false, false, false, false}; @@ -1794,7 +1794,7 @@ TEST(columnTest, json_column_logic_op) { taosMemoryFree(rightData); } - printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + (void)printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); key = "k9"; bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, true, true}; @@ -1811,14 +1811,14 @@ TEST(columnTest, json_column_logic_op) { for (int i = len; i < len + len1; i++) { void *rightData = prepareNchar(inputNchar[i - len]); if (i == 11) { - printf("abc\n"); + (void)printf("abc\n"); } code = makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false); ASSERT_EQ(code, TSDB_CODE_SUCCESS); taosMemoryFree(rightData); } - printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + (void)printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL bool eRes9[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; diff --git a/source/libs/stream/inc/streamBackendRocksdb.h b/source/libs/stream/inc/streamBackendRocksdb.h index c3eeb12209..0f158591b4 100644 --- a/source/libs/stream/inc/streamBackendRocksdb.h +++ b/source/libs/stream/inc/streamBackendRocksdb.h @@ -143,9 +143,9 @@ SListNode* streamBackendAddCompare(void* backend, void* arg); void streamBackendDelCompare(void* backend, void* arg); int32_t streamStateCvtDataFormat(char* path, char* key, void* cfInst); -STaskDbWrapper* taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer); -void taskDbDestroy(void* pBackend, bool flush); -void taskDbDestroy2(void* pBackend); +int32_t taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer, STaskDbWrapper** ppTaskDb); +void taskDbDestroy(void* pBackend, bool flush); +void taskDbDestroy2(void* pBackend); void taskDbUpdateChkpId(void* pTaskDb, int64_t chkpId); @@ -252,7 +252,7 @@ int32_t taskDbDestroySnap(void* arg, SArray* pSnapInfo); int32_t taskDbDoCheckpoint(void* arg, int64_t chkpId, int64_t processId); -SBkdMgt* bkdMgtCreate(char* path); +int32_t bkdMgtCreate(char* path, SBkdMgt **bm); int32_t bkdMgtAddChkp(SBkdMgt* bm, char* task, char* path); int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, char* name); int32_t bkdMgtDumpTo(SBkdMgt* bm, char* taskId, char* dname); diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 869877c9a8..09f6573052 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -2525,35 +2525,35 @@ _EXIT: return NULL; } -STaskDbWrapper* taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer) { +int32_t taskDbOpen(const char* path, const char* key, int64_t chkptId, int64_t* processVer, STaskDbWrapper** ppTaskDb) { char* statePath = NULL; char* dbPath = NULL; int code = 0; - terrno = 0; if ((code = restoreCheckpointData(path, key, chkptId, &statePath, &dbPath, processVer)) < 0) { - terrno = code; stError("failed to restore checkpoint data, path:%s, key:%s, checkpointId: %" PRId64 "reason:%s", path, key, - chkptId, tstrerror(terrno)); - return NULL; + chkptId, tstrerror(code)); + return code; } STaskDbWrapper* pTaskDb = taskDbOpenImpl(key, statePath, dbPath); if (pTaskDb != NULL) { int64_t chkpId = -1, ver = -1; - if ((code = chkpLoadExtraInfo(dbPath, &chkpId, &ver) == 0)) { + if ((code = chkpLoadExtraInfo(dbPath, &chkpId, &ver)) == 0) { *processVer = ver; } else { - terrno = code; stError("failed to load extra info, path:%s, key:%s, checkpointId: %" PRId64 "reason:%s", path, key, chkptId, - tstrerror(terrno)); + tstrerror(code)); taskDbDestroy(pTaskDb, false); - return NULL; + return code; } + } else { + code = TSDB_CODE_INVALID_PARA; } taosMemoryFree(dbPath); taosMemoryFree(statePath); - return pTaskDb; + *ppTaskDb = pTaskDb; + return code; } void taskDbDestroy(void* pDb, bool flush) { @@ -2794,8 +2794,10 @@ int32_t streamStateCvtDataFormat(char* path, char* key, void* pCfInst) { int32_t code = 0; int64_t processVer = -1; - STaskDbWrapper* pTaskDb = taskDbOpen(path, key, 0, &processVer); - RocksdbCfInst* pSrcBackend = pCfInst; + STaskDbWrapper* pTaskDb = NULL; + + code = taskDbOpen(path, key, 0, &processVer, &pTaskDb); + RocksdbCfInst* pSrcBackend = pCfInst; for (int i = 0; i < nCf; i++) { rocksdb_column_family_handle_t* pSrcCf = pSrcBackend->pHandle[i]; @@ -4626,10 +4628,11 @@ int32_t dbChkpGetDelta(SDbChkp* p, int64_t chkpId, SArray* list) { void dbChkpDestroy(SDbChkp* pChkp); -SDbChkp* dbChkpCreate(char* path, int64_t initChkpId) { +int32_t dbChkpCreate(char* path, int64_t initChkpId, SDbChkp** ppChkp) { + int32_t code = 0; SDbChkp* p = taosMemoryCalloc(1, sizeof(SDbChkp)); if (p == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } @@ -4637,41 +4640,41 @@ SDbChkp* dbChkpCreate(char* path, int64_t initChkpId) { p->preCkptId = -1; p->pSST = taosArrayInit(64, sizeof(void*)); if (p->pSST == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; dbChkpDestroy(p); - return NULL; + return code; } p->path = path; p->len = strlen(path) + 128; p->buf = taosMemoryCalloc(1, p->len); if (p->buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->idx = 0; p->pSstTbl[0] = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (p->pSstTbl[0] == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pSstTbl[1] = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (p->pSstTbl[1] == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pAdd = taosArrayInit(64, sizeof(void*)); if (p->pAdd == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } p->pDel = taosArrayInit(64, sizeof(void*)); if (p->pDel == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _EXIT; } @@ -4679,15 +4682,15 @@ SDbChkp* dbChkpCreate(char* path, int64_t initChkpId) { taosThreadRwlockInit(&p->rwLock, NULL); SArray* list = NULL; - int32_t code = dbChkpGetDelta(p, initChkpId, list); + code = dbChkpGetDelta(p, initChkpId, list); if (code != 0) { goto _EXIT; } - - return p; + *ppChkp = p; + return code; _EXIT: dbChkpDestroy(p); - return NULL; + return code; } void dbChkpDestroy(SDbChkp* pChkp) { @@ -4880,35 +4883,36 @@ _ERROR: return code; } -SBkdMgt* bkdMgtCreate(char* path) { - terrno = 0; +int32_t bkdMgtCreate(char* path, SBkdMgt** mgt) { + int32_t code = 0; SBkdMgt* p = taosMemoryCalloc(1, sizeof(SBkdMgt)); if (p == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + code = TSDB_CODE_OUT_OF_MEMORY; + return code; } p->pDbChkpTbl = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (p->pDbChkpTbl == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; bkdMgtDestroy(p); - return NULL; + return code; } p->path = taosStrdup(path); if (p->path == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; bkdMgtDestroy(p); - return NULL; + return code; } if (taosThreadRwlockInit(&p->rwLock, NULL) != 0) { - terrno = TAOS_SYSTEM_ERROR(errno); + code = TAOS_SYSTEM_ERROR(errno); bkdMgtDestroy(p); - return NULL; + return code; } + *mgt = p; - return p; + return code; } void bkdMgtDestroy(SBkdMgt* bm) { @@ -4949,11 +4953,11 @@ int32_t bkdMgtGetDelta(SBkdMgt* bm, char* taskId, int64_t chkpId, SArray* list, return code; } - SDbChkp* p = dbChkpCreate(path, chkpId); - if (p == NULL) { + SDbChkp* p = NULL; + code = dbChkpCreate(path, chkpId, &p); + if (code != 0) { taosMemoryFree(path); taosThreadRwlockUnlock(&bm->rwLock); - code = terrno; return code; } @@ -4986,8 +4990,9 @@ int32_t bkdMgtAddChkp(SBkdMgt* bm, char* task, char* path) { taosThreadRwlockWrlock(&bm->rwLock); SDbChkp** pp = taosHashGet(bm->pDbChkpTbl, task, strlen(task)); if (pp == NULL) { - SDbChkp* p = dbChkpCreate(path, 0); - if (p != NULL) { + SDbChkp* p = NULL; + code = dbChkpCreate(path, 0, &p); + if (code != 0) { taosHashPut(bm->pDbChkpTbl, task, strlen(task), &p, sizeof(void*)); code = 0; } diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 7b410501ca..81640e0050 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -68,12 +68,12 @@ static void streamMetaEnvInit() { } } -void streamMetaInit() { (void) taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } +void streamMetaInit() { (void)taosThreadOnce(&streamMetaModuleInit, streamMetaEnvInit); } void streamMetaCleanup() { - (void) taosCloseRef(streamBackendId); - (void) taosCloseRef(streamBackendCfWrapperId); - (void) taosCloseRef(streamMetaId); + (void)taosCloseRef(streamBackendId); + (void)taosCloseRef(streamBackendCfWrapperId); + (void)taosCloseRef(streamMetaId); metaRefMgtCleanup(); streamTimerCleanUp(); @@ -128,12 +128,12 @@ int32_t metaRefMgtAdd(int64_t vgId, int64_t* rid) { code = taosHashPut(gMetaRefMgt.pTable, &vgId, sizeof(vgId), &list, sizeof(void*)); if (code) { - stError("vgId:%d failed to put into metaRef table, rid:%" PRId64, (int32_t) vgId, *rid); + stError("vgId:%d failed to put into metaRef table, rid:%" PRId64, (int32_t)vgId, *rid); return code; } } else { SArray* list = *(SArray**)p; - void* px = taosArrayPush(list, &rid); + void* px = taosArrayPush(list, &rid); if (px == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; } @@ -186,7 +186,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) { code = tdbTbcMoveToFirst(pCur); if (code) { - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); stError("vgId:%d failed to open stream meta file cursor, not perform compatible check", pMeta->vgId); return ret; } @@ -215,7 +215,7 @@ int32_t streamMetaCheckBackendCompatible(SStreamMeta* pMeta) { tdbFree(pKey); tdbFree(pVal); - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return ret; } @@ -276,6 +276,7 @@ int32_t streamMetaMayCvtDbFormat(SStreamMeta* pMeta) { } int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) { + int32_t code = 0; int64_t chkpId = pTask->chkInfo.checkpointId; streamMutexLock(&pMeta->backendMutex); @@ -299,8 +300,8 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) STaskDbWrapper* pBackend = NULL; int64_t processVer = -1; while (1) { - pBackend = taskDbOpen(pMeta->path, key, chkpId, &processVer); - if (pBackend != NULL) { + code = taskDbOpen(pMeta->path, key, chkpId, &processVer, &pBackend); + if (code == 0) { break; } @@ -319,7 +320,7 @@ int32_t streamTaskSetDb(SStreamMeta* pMeta, SStreamTask* pTask, const char* key) if (processVer != -1) pTask->chkInfo.processedVer = processVer; - int32_t code = taosHashPut(pMeta->pTaskDbUnique, key, strlen(key), &pBackend, sizeof(void*)); + code = taosHashPut(pMeta->pTaskDbUnique, key, strlen(key), &pBackend, sizeof(void*)); if (code) { stError("s-task:0x%x failed to put taskDb backend, code:out of memory", pTask->id.taskId); } @@ -469,8 +470,8 @@ int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild buildTaskFn, pMeta->qHandle = taosInitScheduler(32, 1, "stream-chkp", NULL); - pMeta->bkdChkptMgt = bkdMgtCreate(tpath); - if (pMeta->bkdChkptMgt == NULL) { + code = bkdMgtCreate(tpath, (SBkdMgt**)&pMeta->bkdChkptMgt); + if (code != 0) { goto _err; } @@ -485,7 +486,7 @@ _err: if (pMeta->pTaskList) taosArrayDestroy(pMeta->pTaskList); if (pMeta->pTaskDb) (void)tdbTbClose(pMeta->pTaskDb); if (pMeta->pCheckpointDb) (void)tdbTbClose(pMeta->pCheckpointDb); - if (pMeta->db) (void) tdbClose(pMeta->db); + if (pMeta->db) (void)tdbClose(pMeta->db); if (pMeta->pHbInfo) taosMemoryFreeClear(pMeta->pHbInfo); if (pMeta->updateInfo.pTasks) taosHashCleanup(pMeta->updateInfo.pTasks); if (pMeta->startInfo.pReadyTaskSet) taosHashCleanup(pMeta->startInfo.pReadyTaskSet); @@ -531,7 +532,7 @@ void streamMetaClear(SStreamMeta* pMeta) { // release the ref by timer if (p->info.delaySchedParam != 0 && p->info.fillHistory == 0) { // one more ref in timer stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", p->id.idStr, p->refCnt); - (void) taosTmrStop(p->schedInfo.pDelayTimer); + (void)taosTmrStop(p->schedInfo.pDelayTimer); p->info.delaySchedParam = 0; streamMetaReleaseTask(pMeta, p); } @@ -566,7 +567,7 @@ void streamMetaClose(SStreamMeta* pMeta) { if (pMeta == NULL) { return; } - (void) taosRemoveRef(streamMetaId, pMeta->rid); + (void)taosRemoveRef(streamMetaId, pMeta->rid); } void streamMetaCloseImpl(void* arg) { @@ -583,10 +584,10 @@ void streamMetaCloseImpl(void* arg) { streamMetaWUnLock(pMeta); // already log the error, ignore here - (void) tdbAbort(pMeta->db, pMeta->txn); - (void) tdbTbClose(pMeta->pTaskDb); - (void) tdbTbClose(pMeta->pCheckpointDb); - (void) tdbClose(pMeta->db); + (void)tdbAbort(pMeta->db, pMeta->txn); + (void)tdbTbClose(pMeta->pTaskDb); + (void)tdbTbClose(pMeta->pCheckpointDb); + (void)tdbClose(pMeta->db); taosArrayDestroy(pMeta->pTaskList); taosArrayDestroy(pMeta->chkpSaved); @@ -610,7 +611,7 @@ void streamMetaCloseImpl(void* arg) { bkdMgtDestroy(pMeta->bkdChkptMgt); pMeta->role = NODE_ROLE_UNINIT; - (void) taosThreadRwlockDestroy(&pMeta->lock); + (void)taosThreadRwlockDestroy(&pMeta->lock); taosMemoryFree(pMeta); stDebug("vgId:%d end to close stream meta", vgId); @@ -691,13 +692,13 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa p = taosArrayPush(pMeta->pTaskList, &pTask->id); if (p == NULL) { - stError("s-task:0x%"PRIx64" failed to register task into meta-list, code: out of memory", id.taskId); + stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); return TSDB_CODE_OUT_OF_MEMORY; } code = taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES); if (code) { - stError("s-task:0x%"PRIx64" failed to register task into meta-list, code: out of memory", id.taskId); + stError("s-task:0x%" PRIx64 " failed to register task into meta-list, code: out of memory", id.taskId); return code; } @@ -710,7 +711,7 @@ int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTa } if (pTask->info.fillHistory == 0) { - (void) atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } *pAdded = true; @@ -779,7 +780,7 @@ static void doRemoveIdFromList(SArray* pTaskList, int32_t num, SStreamTaskId* id static int32_t streamTaskSendTransSuccessMsg(SStreamTask* pTask, void* param) { if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - (void) streamTaskSendCheckpointSourceRsp(pTask); + (void)streamTaskSendCheckpointSourceRsp(pTask); } return 0; } @@ -802,7 +803,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t } // handle the dropping event - (void) streamTaskHandleEventAsync(pTask->status.pSM, TASK_EVENT_DROPPING, streamTaskSendTransSuccessMsg, NULL); + (void)streamTaskHandleEventAsync(pTask->status.pSM, TASK_EVENT_DROPPING, streamTaskSendTransSuccessMsg, NULL); } else { stDebug("vgId:%d failed to find the task:0x%x, it may be dropped already", pMeta->vgId, taskId); streamMetaWUnLock(pMeta); @@ -841,12 +842,12 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t pTask = *ppTask; // it is an fill-history task, remove the related stream task's id that points to it if (pTask->info.fillHistory == 0) { - (void) atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); } - (void) taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); + (void)taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); doRemoveIdFromList(pMeta->pTaskList, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id); - (void) streamMetaRemoveTask(pMeta, &id); + (void)streamMetaRemoveTask(pMeta, &id); ASSERT(taosHashGetSize(pMeta->pTasksMap) == taosArrayGetSize(pMeta->pTaskList)); streamMetaWUnLock(pMeta); @@ -854,7 +855,7 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t ASSERT(pTask->status.timerActive == 0); if (pTask->info.delaySchedParam != 0 && pTask->info.fillHistory == 0) { stDebug("s-task:%s stop schedTimer, and (before) desc ref:%d", pTask->id.idStr, pTask->refCnt); - (void) taosTmrStop(pTask->schedInfo.pDelayTimer); + (void)taosTmrStop(pTask->schedInfo.pDelayTimer); pTask->info.delaySchedParam = 0; streamMetaReleaseTask(pMeta, pTask); } @@ -915,7 +916,7 @@ int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta) { code = tdbTbcMoveToFirst(pCur); if (code) { - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); stError("failed to open stream meta file cursor, the latest checkpointId is 0, vgId:%d", pMeta->vgId); return checkpointId; } @@ -953,7 +954,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { SDecoder decoder; int32_t vgId = 0; int32_t code = 0; - SArray* pRecycleList = NULL; + SArray* pRecycleList = NULL; if (pMeta == NULL) { return; @@ -975,7 +976,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (code) { stError("vgId:%d failed to open stream meta cursor, code:%s, not load any stream tasks", vgId, tstrerror(terrno)); taosArrayDestroy(pRecycleList); - (void) tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return; } @@ -1008,7 +1009,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { tFreeStreamTask(pTask); STaskId id = streamTaskGetTaskId(pTask); - (void) taosArrayPush(pRecycleList, &id); + (void)taosArrayPush(pRecycleList, &id); int32_t total = taosArrayGetSize(pRecycleList); stDebug("s-task:0x%x is already dropped, add into recycle list, total:%d", taskId, total); @@ -1029,7 +1030,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { continue; } - (void) taosArrayPush(pMeta->pTaskList, &pTask->id); + (void)taosArrayPush(pMeta->pTaskList, &pTask->id); } else { // todo this should replace the existed object put by replay creating stream task msg from mnode stError("s-task:0x%x already added into table meta by replaying WAL, need check", pTask->id.taskId); @@ -1039,17 +1040,17 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (taosHashPut(pMeta->pTasksMap, &id, sizeof(id), &pTask, POINTER_BYTES) != 0) { stError("s-task:0x%x failed to put into hashTable, code:%s, continue", pTask->id.taskId, tstrerror(terrno)); - (void) taosArrayPop(pMeta->pTaskList); + (void)taosArrayPop(pMeta->pTaskList); tFreeStreamTask(pTask); continue; } if (pTask->info.fillHistory == 0) { - (void) atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfStreamTasks, 1); } if (streamTaskShouldPause(pTask)) { - (void) atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); + (void)atomic_add_fetch_32(&pMeta->numOfPausedTasks, 1); } ASSERT(pTask->status.downstreamReady == 0); @@ -1065,7 +1066,7 @@ void streamMetaLoadAllTasks(SStreamMeta* pMeta) { if (taosArrayGetSize(pRecycleList) > 0) { for (int32_t i = 0; i < taosArrayGetSize(pRecycleList); ++i) { STaskId* pId = taosArrayGet(pRecycleList, i); - (void) streamMetaRemoveTask(pMeta, pId); + (void)streamMetaRemoveTask(pMeta, pId); } } @@ -1093,7 +1094,7 @@ bool streamMetaTaskInTimer(SStreamMeta* pMeta) { SStreamTask* pTask = *(SStreamTask**)pIter; if (pTask->status.timerActive >= 1) { stDebug("s-task:%s in timer, blocking tasks in vgId:%d restart, set closing again", pTask->id.idStr, pMeta->vgId); - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); inTimer = true; } } @@ -1126,7 +1127,7 @@ void streamMetaNotifyClose(SStreamMeta* pMeta) { SStreamTask* pTask = *(SStreamTask**)pIter; stDebug("vgId:%d s-task:%s set task closing flag", vgId, pTask->id.idStr); - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); } streamMetaWUnLock(pMeta); @@ -1173,7 +1174,7 @@ void streamMetaResetStartInfo(STaskStartInfo* pStartInfo, int32_t vgId) { void streamMetaRLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-rlock", pMeta->vgId); - (void) taosThreadRwlockRdlock(&pMeta->lock); + (void)taosThreadRwlockRdlock(&pMeta->lock); } void streamMetaRUnLock(SStreamMeta* pMeta) { @@ -1188,13 +1189,13 @@ void streamMetaRUnLock(SStreamMeta* pMeta) { void streamMetaWLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-wlock", pMeta->vgId); - (void) taosThreadRwlockWrlock(&pMeta->lock); + (void)taosThreadRwlockWrlock(&pMeta->lock); // stTrace("vgId:%d meta-wlock completed", pMeta->vgId); } void streamMetaWUnLock(SStreamMeta* pMeta) { // stTrace("vgId:%d meta-wunlock", pMeta->vgId); - (void) taosThreadRwlockUnlock(&pMeta->lock); + (void)taosThreadRwlockUnlock(&pMeta->lock); } int32_t streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta, SArray** pList) { @@ -1320,7 +1321,7 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { code = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, pTaskId->taskId); - (void) streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); + (void)streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); continue; } @@ -1343,7 +1344,7 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { code = streamMetaAcquireTask(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x during start tasks", pMeta->vgId, pTaskId->taskId); - (void) streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); + (void)streamMetaAddFailedTask(pMeta, pTaskId->streamId, pTaskId->taskId); continue; } @@ -1361,10 +1362,11 @@ int32_t streamMetaStartAllTasks(SStreamMeta* pMeta) { if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { stDebug("s-task:%s downstream ready, no need to check downstream, check only related fill-history task", pTask->id.idStr); - (void) streamLaunchFillHistoryTask(pTask); // todo: how about retry launch fill-history task? + (void)streamLaunchFillHistoryTask(pTask); // todo: how about retry launch fill-history task? } - (void) streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, pInfo->checkTs, pInfo->readyTs, true); + (void)streamMetaAddTaskLaunchResult(pMeta, pTaskId->streamId, pTaskId->taskId, pInfo->checkTs, pInfo->readyTs, + true); streamMetaReleaseTask(pMeta, pTask); continue; } @@ -1420,14 +1422,14 @@ int32_t streamMetaStopAllTasks(SStreamMeta* pMeta) { for (int32_t i = 0; i < numOfTasks; ++i) { SStreamTaskId* pTaskId = taosArrayGet(pTaskList, i); - SStreamTask* pTask = NULL; + SStreamTask* pTask = NULL; code = streamMetaAcquireTaskNoLock(pMeta, pTaskId->streamId, pTaskId->taskId, &pTask); if (code != TSDB_CODE_SUCCESS) { continue; } - (void) streamTaskStop(pTask); + (void)streamTaskStop(pTask); streamMetaReleaseTask(pMeta, pTask); } @@ -1467,7 +1469,7 @@ int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t tas code = streamMetaAcquireTask(pMeta, streamId, taskId, &pTask); if (pTask == NULL) { stError("vgId:%d failed to acquire task:0x%x when starting task", pMeta->vgId, taskId); - (void) streamMetaAddFailedTask(pMeta, streamId, taskId); + (void)streamMetaAddFailedTask(pMeta, streamId, taskId); return TSDB_CODE_STREAM_TASK_IVLD_STATUS; } @@ -1558,9 +1560,8 @@ int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int3 SHashObj* pDst = ready ? pStartInfo->pReadyTaskSet : pStartInfo->pFailedTaskSet; STaskInitTs initTs = {.start = startTs, .end = endTs, .success = ready}; - int32_t code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); + int32_t code = taosHashPut(pDst, &id, sizeof(id), &initTs, sizeof(STaskInitTs)); if (code) { - } int32_t numOfTotal = streamMetaGetNumOfTasks(pMeta); @@ -1632,9 +1633,9 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta streamMetaRUnLock(pMeta); // add the failed task info, along with the related fill-history task info into tasks list. - (void) streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, startTs, now, false); + (void)streamMetaAddTaskLaunchResult(pMeta, streamId, taskId, startTs, now, false); if (hasFillhistoryTask) { - (void) streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false); + (void)streamMetaAddTaskLaunchResult(pMeta, hId.streamId, hId.taskId, startTs, now, false); } } else { streamMetaRUnLock(pMeta); @@ -1649,12 +1650,12 @@ int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t ta void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs) { int32_t startTs = pTask->execInfo.checkTs; - (void) streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, failedTs, false); + (void)streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, startTs, failedTs, false); // automatically set the related fill-history task to be failed. if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { STaskId* pId = &pTask->hTaskInfo.id; - (void) streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, failedTs, false); + (void)streamMetaAddTaskLaunchResult(pTask->pMeta, pId->streamId, pId->taskId, startTs, failedTs, false); } } @@ -1662,7 +1663,7 @@ void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SSt int64_t startTs) { const char* id = pTask->id.idStr; int32_t vgId = pTask->pMeta->vgId; - int32_t code = 0; + int32_t code = 0; // keep the already updated info STaskUpdateEntry entry = {.streamId = pTask->id.streamId, .taskId = pTask->id.taskId, .transId = transId}; diff --git a/source/libs/stream/test/backendTest.cpp b/source/libs/stream/test/backendTest.cpp index 1b2f961726..2b21510e45 100644 --- a/source/libs/stream/test/backendTest.cpp +++ b/source/libs/stream/test/backendTest.cpp @@ -69,7 +69,7 @@ void *backendOpen() { key.ts = ts; const char *val = "value data"; int32_t vlen = strlen(val); - int32_t code = streamStatePut_rocksdb(p, &key, (char *)val, vlen); + int32_t code = streamStatePut_rocksdb(p, &key, (char *)val, vlen); ASSERT(code == 0); tsArray.push_back(ts); @@ -83,7 +83,7 @@ void *backendOpen() { const char *val = "value data"; int32_t len = 0; char *newVal = NULL; - int32_t code = streamStateGet_rocksdb(p, &key, (void **)&newVal, &len); + int32_t code = streamStateGet_rocksdb(p, &key, (void **)&newVal, &len); ASSERT(code == 0); ASSERT(len == strlen(val)); @@ -377,7 +377,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatch(p, "default", (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000); + (int32_t)(strlen(val)), tsStart + 100000); ASSERT(code == 0); } @@ -396,7 +396,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatchOptimize(p, 0, (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); + (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); ASSERT(code == 0); } int32_t code = streamStatePutBatch_rocksdb(p, pBatch); @@ -417,7 +417,7 @@ TEST_F(BackendEnv, checkOpen) { char val[128] = {0}; sprintf(val, "val_%d", i); int32_t code = streamStatePutBatchOptimize(p, 0, (rocksdb_writebatch_t *)pBatch, (void *)key, (void *)val, - (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); + (int32_t)(strlen(val)), tsStart + 100000, (void *)valBuf); ASSERT(code == 0); } code = streamStatePutBatch_rocksdb(p, pBatch); @@ -432,13 +432,12 @@ TEST_F(BackendEnv, checkOpen) { const char *path = "/tmp/backend/stream"; const char *dump = "/tmp/backend/stream/dump"; // taosMkDir(dump); - code = taosMulMkDir(dump); - ASSERT(code == 0); + taosMulMkDir(dump); + SBkdMgt *mgt = NULL; - SBkdMgt *mgt = bkdMgtCreate((char *)path); - SArray *result = taosArrayInit(4, sizeof(void *)); - code = bkdMgtGetDelta(mgt, p->pTdbState->idstr, 3, result, (char *)dump); - ASSERT(code == 0); + code = bkdMgtCreate((char *)path, &mgt); + SArray *result = taosArrayInit(4, sizeof(void *)); + bkdMgtGetDelta(mgt, p->pTdbState->idstr, 3, result, (char *)dump); code = taskDbDoCheckpoint(p->pTdbState->pOwner->pBackend, 4, 0); ASSERT(code == 0); @@ -475,7 +474,7 @@ TEST_F(BackendEnv, backendUtil) { } TEST_F(BackendEnv, oldBackendInit) { const char *path = "/tmp/backend1"; - int32_t code = taosMulMkDir(path); + int32_t code = taosMulMkDir(path); ASSERT(code == 0); { diff --git a/source/libs/stream/test/tstreamUpdateTest.cpp b/source/libs/stream/test/tstreamUpdateTest.cpp index 59171876ff..4360fc7d54 100644 --- a/source/libs/stream/test/tstreamUpdateTest.cpp +++ b/source/libs/stream/test/tstreamUpdateTest.cpp @@ -53,7 +53,7 @@ TEST(TD_STREAM_UPDATE_TEST, update) { void *p = NULL; // SBackendWrapper *p = streamBackendInit(streamPath, -1, 2); // p = taskDbOpen((char *)streamPath, (char *)"test", -1); - p = bkdMgtCreate((char *)streamPath); + int32_t code = bkdMgtCreate((char *)streamPath, (SBkdMgt **)&p); // const int64_t interval = 20 * 1000; // const int64_t watermark = 10 * 60 * 1000; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index 8b6092e839..ef2cbece79 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -134,7 +134,7 @@ int32_t syncLogReplGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncI } SSnapshot snapshot = {0}; - (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); // TODO: check the return code + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); if (prevIndex == snapshot.lastApplyIndex) { *pSyncTerm = snapshot.lastApplyTerm; return 0; @@ -184,7 +184,7 @@ int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) { int32_t code = 0, lino = 0; SSnapshot snapshot = {0}; - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + TAOS_CHECK_EXIT(pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot)); SyncIndex commitIndex = snapshot.lastApplyIndex; SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index cb07a63eed..cc2aa7d91e 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -134,7 +134,7 @@ int32_t raftStoreWriteFile(SSyncNode *pNode) { if (taosFsyncFile(pFile) < 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); if (taosRenameFile(file, realfile) != 0) TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), &lino, _OVER); code = 0; diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 40a359379a..8644ba6bb9 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -84,7 +84,7 @@ int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { SyncAppendEntries* pMsg = pRpcMsg->pCont; pMsg->destId = *destRaftId; - syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); + (void)syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -113,7 +113,7 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode) { // send msg syncLogSendHeartbeat(pSyncNode, pSyncMsg, true, 0, 0); - syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); + (void)syncNodeSendHeartbeat(pSyncNode, &pSyncMsg->destId, &rpcMsg); } TAOS_RETURN(TSDB_CODE_SUCCESS); diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 0e50cca94c..a30b9a4930 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -135,7 +135,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // trace log syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, ""); syncLogSendRequestVoteReply(ths, pReply, ""); - syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + (void)syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); if (resetElect) syncNodeResetElectTimer(ths); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 450d22528d..8a2c53997b 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -86,14 +86,17 @@ int32_t snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaIndex, SSyncSn pSender->replicaIndex = replicaIndex; pSender->term = raftStoreGetTerm(pSyncNode); pSender->startTime = -1; - pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); pSender->finish = false; + code = pSender->pSyncNode->pFsm->FpGetSnapshotInfo(pSender->pSyncNode->pFsm, &pSender->snapshot); + if (code != 0) { + taosMemoryFreeClear(pSender); + TAOS_RETURN(code); + } SSyncSnapBuffer *pSndBuf = NULL; code = syncSnapBufferCreate(&pSndBuf); if (pSndBuf == NULL) { - taosMemoryFree(pSender); - pSender = NULL; + taosMemoryFreeClear(pSender); TAOS_RETURN(code); } pSndBuf->entryDeleteCb = syncSnapBlockDestroy; @@ -472,7 +475,7 @@ void snapshotReceiverDestroy(SSyncSnapshotReceiver *pReceiver) { syncSnapBufferDestroy(&pReceiver->pRcvBuf); } - snapshotReceiverClearInfoData(pReceiver); + (void)snapshotReceiverClearInfoData(pReceiver); // free receiver taosMemoryFree(pReceiver); @@ -592,7 +595,7 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap code = pReceiver->pSyncNode->pFsm->FpSnapshotStopWrite(pReceiver->pSyncNode->pFsm, pReceiver->pWriter, true, &pReceiver->snapshot); if (code != 0) { - sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code)); + sRError(pReceiver, "snapshot receiver apply failed since %s", tstrerror(code)); TAOS_RETURN(code); } pReceiver->pWriter = NULL; @@ -603,7 +606,11 @@ static int32_t snapshotReceiverFinish(SSyncSnapshotReceiver *pReceiver, SyncSnap // get fsmState SSnapshot snapshot = {0}; - pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + code = pReceiver->pSyncNode->pFsm->FpGetSnapshotInfo(pReceiver->pSyncNode->pFsm, &snapshot); + if (code != 0) { + sRError(pReceiver, "snapshot receiver get snapshot info failed since %s", tstrerror(code)); + TAOS_RETURN(code); + } pReceiver->pSyncNode->fsmState = snapshot.state; // reset wal @@ -1276,13 +1283,13 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { sSInfo(pSender, "process end rsp"); snapshotSenderStop(pSender, true); - syncNodeReplicateReset(pSyncNode, &pMsg->srcId); + (void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId); } return 0; _ERROR: snapshotSenderStop(pSender, false); - syncNodeReplicateReset(pSyncNode, &pMsg->srcId); + (void)syncNodeReplicateReset(pSyncNode, &pMsg->srcId); TAOS_RETURN(code); } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 2076de6ec7..49737b9045 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -183,7 +183,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; @@ -253,7 +253,7 @@ void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dfla SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; @@ -302,7 +302,7 @@ void syncPrintSnapshotReceiverLog(const char* flags, ELogLevel level, int32_t df SSnapshot snapshot = {.data = NULL, .lastApplyIndex = -1, .lastApplyTerm = 0}; if (pNode->pFsm != NULL && pNode->pFsm->FpGetSnapshotInfo != NULL) { - pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); + (void)pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot); } SyncIndex logLastIndex = SYNC_INDEX_INVALID; diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index d3a5711352..0935e87ab0 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -48,7 +48,7 @@ int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyC int8_t rollback); int32_t tdbTbClose(TTB *pTb); bool tdbTbExist(const char *tbname, TDB *pEnv); -int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN* pTxn); +int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN *pTxn); int32_t tdbTbDrop(TTB *pTb); int32_t tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int valLen, TXN *pTxn); int32_t tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn); @@ -80,10 +80,10 @@ int32_t tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, i int32_t tdbTxnOpen(TXN *pTxn, int64_t txnid, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, int flags); int32_t tdbTxnCloseImpl(TXN *pTxn); -#define tdbTxnClose(pTxn) \ - do { \ - tdbTxnCloseImpl(pTxn); \ - (pTxn) = NULL; \ +#define tdbTxnClose(pTxn) \ + do { \ + (void)tdbTxnCloseImpl(pTxn); \ + (pTxn) = NULL; \ } while (0) // other diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index f86ed69fc3..487ec1dac5 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -122,7 +122,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg zArg.pBt = pBt; ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -130,7 +130,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbPagerWrite(pPager, pPage); if (ret < 0) { tdbError("failed to write page since %s", terrstr()); - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -143,7 +143,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -194,14 +194,14 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in int idx; int c; - tdbBtcOpen(&btc, pBt, pTxn); + (void)tdbBtcOpen(&btc, pBt, pTxn); tdbTrace("tdb insert, btc: %p, pTxn: %p", &btc, pTxn); // move to the position to insert ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret); return ret; } @@ -213,7 +213,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in btc.idx++; } else if (c == 0) { // dup key not allowed with insert - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn); return TSDB_CODE_DUP_KEY; } @@ -221,12 +221,12 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret); return ret; } - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -246,20 +246,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { // move the cursor ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || c != 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } // delete the key ret = tdbBtcDelete(&btc); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return ret; } /* @@ -274,7 +274,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { btc.coder.ofps = NULL; } */ - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -343,20 +343,20 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || cret) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } pCell = tdbPageGetCell(btc.pPage, btc.idx); ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret); return ret; } @@ -364,7 +364,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppKey) { pTKey = tdbRealloc(*ppKey, cd.kLen); if (pTKey == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTKey failed."); return terrno; } @@ -376,7 +376,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppVal) { pTVal = tdbRealloc(*ppVal, cd.vLen); if (pTVal == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTVal failed."); return terrno; } @@ -397,7 +397,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd); - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -512,7 +512,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild, TXN } // Copy the root page content to the child page - tdbPageCopy(pRoot, pChild, 0); + (void)tdbPageCopy(pRoot, pChild, 0); // Reinitialize the root page zArg.flags = TDB_BTREE_ROOT; @@ -602,7 +602,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx if (i < nOlds - 1) { ((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno; ((SIntHdr *)pOlds[i]->pData)->pgno = 0; - tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); + (void)tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); } } rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno; @@ -626,14 +626,14 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } } - tdbPageDropCell(pParent, sIdx, pTxn, pBt); + (void)tdbPageDropCell(pParent, sIdx, pTxn, pBt); if (!childNotLeaf) { SArray *ofps = pParent->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); + (void)tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); } if (destroyOfps) { @@ -791,9 +791,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx iarg.pBt = pBt; iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]); for (int i = 0; i < nOlds; i++) { - tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); - tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); - tdbPageCopy(pOlds[i], pOldsCopy[i], 0); + (void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); + (void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); + (void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0); pOlds[i]->nOverflow = 0; } @@ -818,7 +818,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } if (nNewCells < infoNews[iNew].cnt) { - tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); + (void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); nNewCells++; // insert parent page @@ -835,9 +835,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx int szNewCell; SPgno pgno; pgno = TDB_PAGE_PGNO(pNews[iNew]); - tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, pTxn, - pBt); - tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); + (void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, + pTxn, pBt); + (void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); tdbOsFree(pNewCell); if (TDB_CELLDECODER_FREE_VAL(&cd)) { @@ -869,7 +869,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx return TSDB_CODE_FAILED; } ((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]); - tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); + (void)tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); // move to next new page iNew++; @@ -892,12 +892,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]); } else { ((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]); - tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); + (void)tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); } } for (int i = 0; i < nOlds; i++) { - tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); + (void)tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); } } @@ -905,13 +905,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]); // copy content to the parent page tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); - tdbPageCopy(pNews[0], pParent, 1); + (void)tdbPageCopy(pNews[0], pParent, 1); if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) { ((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno; } - tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); } for (int i = 0; i < 3; i++) { @@ -922,7 +922,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx for (pageIdx = 0; pageIdx < nOlds; ++pageIdx) { if (pageIdx >= nNews) { - tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); } tdbPagerReturnPage(pBt->pPager, pOlds[pageIdx], pTxn); } @@ -1986,7 +1986,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx++; if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { @@ -2029,7 +2029,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx--; if (pBtc->idx >= 0) { break; @@ -2040,7 +2040,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { for (;;) { if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; } else { @@ -2119,7 +2119,7 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int } pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx); - tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); if (ppKey) { *ppKey = (void *)pBtc->coder.pKey; @@ -2165,13 +2165,13 @@ int tdbBtcDelete(SBTC *pBtc) { destroyOfps = true; } - tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); + (void)tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); SArray *ofps = pBtc->pPage->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); + (void)tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); } if (destroyOfps) { @@ -2184,7 +2184,7 @@ int tdbBtcDelete(SBTC *pBtc) { if (idx == nCells - 1) { if (idx) { pBtc->idx--; - tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); + (void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); // loop to update the interial page pgno = TDB_PAGE_PGNO(pBtc->pPage); @@ -2202,7 +2202,7 @@ int tdbBtcDelete(SBTC *pBtc) { // update the cell with new key pCell = tdbOsMalloc(nKey + 9); - tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); ret = tdbPageUpdateCell(pPage, idx, pCell, szCell, pBtc->pTxn, pBtc->pBt); if (ret < 0) { @@ -2429,7 +2429,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare first cell pBtc->idx = lidx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c <= 0) { ridx = lidx - 1; @@ -2439,7 +2439,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare last cell if (lidx <= ridx) { pBtc->idx = ridx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c >= 0) { lidx = ridx + 1; @@ -2454,7 +2454,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (lidx > ridx) break; pBtc->idx = (lidx + ridx) >> 1; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c < 0) { // pKey < cd.pKey @@ -2476,7 +2476,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (c > 0) { pBtc->idx += 1; } - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); } } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index 47a7b6fe7a..825a6e2b94 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -101,10 +101,10 @@ int tdbClose(TDB *pDb) { for (pPager = pDb->pgrList; pPager; pPager = pDb->pgrList) { pDb->pgrList = pPager->pNext; - tdbPagerClose(pPager); + (void)tdbPagerClose(pPager); } - tdbPCacheClose(pDb->pCache); + (void)tdbPCacheClose(pDb->pCache); tdbOsFree(pDb->pgrHash); tdbOsFree(pDb); } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 6cb5f89758..c1a2943bee 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -44,10 +44,10 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage); static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage); static int tdbPCacheCloseImpl(SPCache *pCache); -static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); } -static void tdbPCacheDestroyLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); } -static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); } -static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); } +static void tdbPCacheInitLock(SPCache *pCache) { (void)tdbMutexInit(&(pCache->mutex), NULL); } +static void tdbPCacheDestroyLock(SPCache *pCache) { (void)tdbMutexDestroy(&(pCache->mutex)); } +static void tdbPCacheLock(SPCache *pCache) { (void)tdbMutexLock(&(pCache->mutex)); } +static void tdbPCacheUnlock(SPCache *pCache) { (void)tdbMutexUnlock(&(pCache->mutex)); } int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { int32_t code = 0; @@ -74,7 +74,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { _exit: if (code) { tdbError("%s failed at %s:%d since %s", __func__, __FILE__, __LINE__, tstrerror(code)); - tdbPCacheClose(pCache); + (void)tdbPCacheClose(pCache); *ppCache = NULL; } else { *ppCache = pCache; @@ -84,7 +84,7 @@ _exit: int tdbPCacheClose(SPCache *pCache) { if (pCache) { - tdbPCacheCloseImpl(pCache); + (void)tdbPCacheCloseImpl(pCache); tdbOsFree(pCache->aPage); tdbOsFree(pCache); } @@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) { SPage *pPage = *ppPage; *ppPage = pPage->pFreeNext; pCache->aPage[pPage->id] = NULL; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pCache->nFree--; } else { ppPage = &(*ppPage)->pFreeNext; @@ -209,7 +209,7 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage)); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -268,7 +268,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) { tdbPCacheRemovePageFromHash(pCache, pPage); } - tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); + (void)tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); } // } } @@ -349,7 +349,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn) for (int nLoops = 0;;) { if (pPageH->pPager) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -432,7 +432,7 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) { // free free page for (SPage *pPage = pCache->pFree; pPage;) { SPage *pPageT = pPage->pFreeNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) { for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) { SPage *pPageT = pPage->pHashNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 322b735163..26c1c108d2 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -64,7 +64,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) memset(ptr, 0, size); pPage = (SPage *)(ptr + pageSize); - TDB_INIT_PAGE_LOCK(pPage); + (void)TDB_INIT_PAGE_LOCK(pPage); pPage->pageSize = pageSize; pPage->pData = ptr; if (pageSize < 65536) { @@ -194,7 +194,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl iOvfl++; } else { // page must has enough space to hold the cell locally - tdbPageAllocate(pPage, szCell, &pNewCell); + (void)tdbPageAllocate(pPage, szCell, &pNewCell); memcpy(pNewCell, pCell, szCell); @@ -220,7 +220,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl } int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) { - tdbPageDropCell(pPage, idx, pTxn, pBt); + (void)tdbPageDropCell(pPage, idx, pTxn, pBt); return tdbPageInsertCell(pPage, idx, pCell, szCell, 0); } @@ -259,7 +259,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) { lidx = idx - iOvfl; pCell = TDB_PAGE_CELL_AT(pPage, lidx); szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt); - tdbPageFree(pPage, lidx, pCell, szCell); + (void)tdbPageFree(pPage, lidx, pCell, szCell); TDB_PAGE_NCELLS_SET(pPage, nCells - 1); for (; iOvfl < pPage->nOverflow; iOvfl++) { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 414ca42a02..01c9132b54 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -107,7 +107,7 @@ static int hashset_add(hashset_t set, void *item) { set->nitems = 0; for (size_t i = 0; i < old_capacity; ++i) { - hashset_add_member(set, (void *)old_items[i]); + (void)hashset_add_member(set, (void *)old_items[i]); } tdbOsFree(old_items); } @@ -223,7 +223,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) { int tdbPagerClose(SPager *pPager) { if (pPager) { - tdbOsClose(pPager->fd); + (void)tdbOsClose(pPager->fd); tdbOsFree(pPager); } return 0; @@ -236,14 +236,14 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { if (pPage->isDirty) return 0; // ref page one more time so the page will not be release - tdbRefPage(pPage); + (void)tdbRefPage(pPage); tdbTrace("pager/mdirty page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); // Set page as dirty pPage->isDirty = 1; tdbTrace("tdb/pager-write: put page: %p %d to dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); - tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); + (void)tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); // Write page to journal if neccessary if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && @@ -256,7 +256,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { } if (pPager->pActiveTxn->jPageSet) { - hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } } @@ -352,7 +352,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); if (pTxn->jPageSet) { - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } tdbTrace("tdb/pager-commit: remove page: %p %d from dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); @@ -590,7 +590,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); tdbPCacheMarkFree(pPager->pCache, pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } @@ -712,7 +712,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPa memcpy(&pgid, pPager->fid, TDB_FILE_ID_LEN); pgid.pgno = pgno; while ((pPage = tdbPCacheFetch(pPager->pCache, &pgid, pTxn)) == NULL) { - tdbPagerFlushPage(pPager, pTxn); + (void)tdbPagerFlushPage(pPager, pTxn); } tdbTrace("tdbttl fetch pager:%p", pPage->pPager); @@ -815,7 +815,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcMoveToFirst(pCur); if (code) { tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -825,7 +825,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL); if (code < 0) { // tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -836,10 +836,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcDelete(pCur); if (code < 0) { tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -892,7 +892,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage lcode = TDB_TRY_LOCK_PAGE(pPage); if (lcode == P_LOCK_SUCC) { if (TDB_PAGE_INITIALIZED(pPage)) { - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return 0; } @@ -906,7 +906,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage tdbTrace("tdb/pager:%p, pgno:%d, nRead:%" PRId64, pPager, pgno, nRead); if (nRead < pPage->pageSize) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32, pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return TAOS_SYSTEM_ERROR(errno); } @@ -953,7 +953,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage if (ret < 0) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32 " init page failed.", pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return ret; } @@ -961,7 +961,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage pPage->pPager = pPager; - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); } else if (lcode == P_LOCK_BUSY) { nLoops = 0; for (;;) { @@ -1162,7 +1162,7 @@ int tdbPagerRestoreJournals(SPager *pPager) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { int64_t txnId = -1; - sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); + (void)sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); if (taosArrayPush(pTxnList, &txnId) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1179,14 +1179,14 @@ int tdbPagerRestoreJournals(SPager *pPager) { code = tdbPagerRestore(pPager, jname); if (code) { taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to restore file due to %s. jFileName:%s", strerror(code), jname); return code; } } taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } @@ -1209,7 +1209,7 @@ int tdbPagerRollback(SPager *pPager) { jname[dirLen] = '/'; memcpy(jname + dirLen + 1, name, strlen(name)); if (tdbOsRemove(jname) < 0 && errno != ENOENT) { - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); return terrno = TAOS_SYSTEM_ERROR(errno); @@ -1217,7 +1217,7 @@ int tdbPagerRollback(SPager *pPager) { } } - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 365be222ef..d885c38864 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -112,7 +112,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF return ret; } } else { - tdbPagerRollback(pPager); + (void)tdbPagerRollback(pPager); } // pTb->pBt @@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF int tdbTbClose(TTB *pTb) { if (pTb) { - tdbBtreeClose(pTb->pBt); + (void)tdbBtreeClose(pTb->pBt); tdbOsFree(pTb); } return 0; @@ -202,7 +202,7 @@ int tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int va int tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn) { return tdbBtreeDelete(pTb->pBt, pKey, kLen, pTxn); } int tdbTbUpsert(TTB *pTb, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) { - tdbTbDelete(pTb, pKey, kLen, pTxn); + (void)tdbTbDelete(pTb, pKey, kLen, pTxn); return tdbTbInsert(pTb, pKey, kLen, pVal, vLen, pTxn); } @@ -224,7 +224,7 @@ int tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn) { return -1; } - tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); + (void)tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); *ppTbc = pTbc; return 0; @@ -238,7 +238,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, return ret; } - tdbTbcMoveToFirst(pCur); + (void)tdbTbcMoveToFirst(pCur); void *pKey = NULL; int kLen = 0; @@ -257,7 +257,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, } tdbFree(pKey); tdbFree(pValue); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -292,7 +292,7 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n int tdbTbcClose(TBC *pTbc) { if (pTbc) { - tdbBtcClose(&pTbc->btc); + (void)tdbBtcClose(&pTbc->btc); tdbOsFree(pTbc); } diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index fe97f9c986..4382513f73 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -13,6 +13,8 @@ * along with this program. If not, see . */ +#include "tdbInt.h" + #ifndef _TDB_UTIL_H_ #define _TDB_UTIL_H_ @@ -56,8 +58,6 @@ static inline int tdbPutVarInt(u8 *p, int v) { v >>= 7; } - ASSERT(n < 6); - return n; } @@ -79,8 +79,6 @@ static inline int tdbGetVarInt(const u8 *p, int *v) { n++; } - ASSERT(n < 6); - *v = tv; return n; } diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index ede7636011..f81bbbdeb7 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -483,7 +483,7 @@ const STfsFile *tfsReaddir(STfsDir *pTfsDir) { void tfsClosedir(STfsDir *pTfsDir) { if (pTfsDir) { if (pTfsDir->pDir != NULL) { - taosCloseDir(&pTfsDir->pDir); + (void)taosCloseDir(&pTfsDir->pDir); pTfsDir->pDir = NULL; } taosMemoryFree(pTfsDir); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index acb9bd20f3..e66941244c 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -103,11 +103,11 @@ typedef void* queue[2]; #define TRANS_MAGIC_NUM 0x5f375a86 #define TRANS_NOVALID_PACKET(src) ((src) != TRANS_MAGIC_NUM ? 1 : 0) -typedef struct SRpcMsg STransMsg; -typedef SRpcCtx STransCtx; -typedef SRpcCtxVal STransCtxVal; -typedef SRpcInfo STrans; -typedef SRpcConnInfo STransHandleInfo; +typedef struct SRpcMsg STransMsg; +typedef SRpcCtx STransCtx; +typedef SRpcCtxVal STransCtxVal; +typedef SRpcInfo STrans; +typedef SRpcConnInfo STransHandleInfo; // ref mgt handle typedef struct SExHandle { @@ -250,10 +250,10 @@ typedef struct { int8_t stop; } SAsyncPool; -SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb); -void transAsyncPoolDestroy(SAsyncPool* pool); -int transAsyncSend(SAsyncPool* pool, queue* mq); -bool transAsyncPoolIsEmpty(SAsyncPool* pool); +int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool); +void transAsyncPoolDestroy(SAsyncPool* pool); +int transAsyncSend(SAsyncPool* pool, queue* mq); +bool transAsyncPoolIsEmpty(SAsyncPool* pool); #define TRANS_DESTROY_ASYNC_POOL_MSG(pool, msgType, freeFunc, param) \ do { \ @@ -279,6 +279,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); if (exh2 == NULL || id != exh2->refId) { \ tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, \ exh2 ? exh2->refId : 0, id); \ + code = terrno; \ goto _return1; \ } \ } else if (id == 0) { \ @@ -287,6 +288,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); if (exh2 == NULL || id == exh2->refId) { \ tTrace("handle %p except, may already freed, ignore msg, ref1:%" PRIu64 ", ref2:%" PRIu64, exh1, id, \ exh2 ? exh2->refId : 0); \ + code = terrno; \ goto _return1; \ } else { \ id = exh1->refId; \ @@ -297,13 +299,13 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool); } \ } while (0) -int transInitBuffer(SConnBuffer* buf); -int transClearBuffer(SConnBuffer* buf); -int transDestroyBuffer(SConnBuffer* buf); -int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf); -bool transReadComplete(SConnBuffer* connBuf); -int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf); -int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf); +int32_t transInitBuffer(SConnBuffer* buf); +int32_t transClearBuffer(SConnBuffer* buf); +int32_t transDestroyBuffer(SConnBuffer* buf); +int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf); +bool transReadComplete(SConnBuffer* connBuf); +int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf); +int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf); int transSetConnOption(uv_tcp_t* stream, int keepalive); @@ -316,14 +318,14 @@ void transUnrefCliHandle(void* handle); int transReleaseCliHandle(void* handle); int transReleaseSrvHandle(void* handle); -int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx); -int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp); -int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated, - int32_t timeoutMs); -int transSendResponse(const STransMsg* msg); -int transRegisterMsg(const STransMsg* msg); -int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn); -void transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func); +int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransCtx* pCtx); +int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp); +int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pMsg, STransMsg* pRsp, int8_t* epUpdated, + int32_t timeoutMs); +int transSendResponse(const STransMsg* msg); +int transRegisterMsg(const STransMsg* msg); +int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn); +int32_t transSetIpWhiteList(void* shandle, void* arg, FilteFunc* func); int transSockInfo2Str(struct sockaddr* sockname, char* dst); @@ -363,7 +365,7 @@ typedef struct { * init queue * note: queue'size is small, default 1 */ -void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)); +int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)); /* * put arg into queue @@ -420,7 +422,7 @@ typedef struct SDelayQueue { uv_loop_t* loop; } SDelayQueue; -int transDQCreate(uv_loop_t* loop, SDelayQueue** queue); +int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue); void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)); SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs); void transDQCancel(SDelayQueue* queue, SDelayTask* task); @@ -433,9 +435,9 @@ bool transEpSetIsEqual2(SEpSet* a, SEpSet* b); */ void transThreadOnce(); -void transInit(); -void transCleanup(); -void transPrintEpSet(SEpSet* pEpSet); +int32_t transInit(); +void transCleanup(); +void transPrintEpSet(SEpSet* pEpSet); void transFreeMsg(void* msg); int32_t transCompressMsg(char* msg, int32_t len); diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index 2a538a416c..d3fe42d2ec 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -76,9 +76,9 @@ static void httpHandleReq(SHttpMsg* msg); static void httpHandleQuit(SHttpMsg* msg); static int32_t httpSendQuit(SHttpModule* http, int64_t chanId); -static int32_t httpCreateMsg(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen, - EHttpCompFlag flag, int64_t chanId, SHttpMsg** httpMsg); -static void httpDestroyMsg(SHttpMsg* msg); +static int32_t httpCreateMsg(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen, + EHttpCompFlag flag, int64_t chanId, SHttpMsg** httpMsg); +static void httpDestroyMsg(SHttpMsg* msg); static bool httpFailFastShoudIgnoreMsg(SHashObj* pTable, char* server, int16_t port); static void httpFailFastMayUpdate(SHashObj* pTable, char* server, int16_t port, int8_t succ); @@ -91,27 +91,27 @@ static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, static int32_t taosBuildHttpHeader(const char* server, const char* uri, int32_t contLen, char* pHead, int32_t headLen, - EHttpCompFlag flag) { - int32_t code = 0; + EHttpCompFlag flag) { + int32_t code = 0; int32_t len = 0; if (flag == HTTP_FLAT) { len = snprintf(pHead, headLen, - "POST %s HTTP/1.1\n" - "Host: %s\n" - "Content-Type: application/json\n" - "Content-Length: %d\n\n", - uri, server, contLen); + "POST %s HTTP/1.1\n" + "Host: %s\n" + "Content-Type: application/json\n" + "Content-Length: %d\n\n", + uri, server, contLen); if (len < 0 || len >= headLen) { code = TSDB_CODE_OUT_OF_RANGE; } } else if (flag == HTTP_GZIP) { len = snprintf(pHead, headLen, - "POST %s HTTP/1.1\n" - "Host: %s\n" - "Content-Type: application/json\n" - "Content-Encoding: gzip\n" - "Content-Length: %d\n\n", - uri, server, contLen); + "POST %s HTTP/1.1\n" + "Host: %s\n" + "Content-Type: application/json\n" + "Content-Encoding: gzip\n" + "Content-Length: %d\n\n", + uri, server, contLen); if (len < 0 || len >= headLen) { code = TSDB_CODE_OUT_OF_RANGE; } @@ -127,7 +127,7 @@ static int32_t taosCompressHttpRport(char* pSrc, int32_t srcLen) { void* pDest = taosMemoryMalloc(destLen); if (pDest == NULL) { - code= TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _OVER; } @@ -184,14 +184,14 @@ _OVER: if (code == 0) { memcpy(pSrc, pDest, gzipStream.total_out); code = gzipStream.total_out; - } + } taosMemoryFree(pDest); return code; } static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port, struct sockaddr_in* dest) { uint32_t ip = 0; - int32_t code = taosGetIpv4FromFqdn(server, &ip); + int32_t code = taosGetIpv4FromFqdn(server, &ip); if (code) { tError("http-report failed to resolving domain names: %s", server); return TSDB_CODE_RPC_FQDN_ERROR; @@ -293,7 +293,7 @@ static void httpAsyncCb(uv_async_t* handle) { static int32_t BATCH_SIZE = 5; int32_t count = 0; - taosThreadMutexLock(&item->mtx); + (void)taosThreadMutexLock(&item->mtx); httpMayDiscardMsg(http, item); while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) { @@ -301,7 +301,7 @@ static void httpAsyncCb(uv_async_t* handle) { QUEUE_REMOVE(h); QUEUE_PUSH(&wq, h); } - taosThreadMutexUnlock(&item->mtx); + (void)taosThreadMutexUnlock(&item->mtx); while (!QUEUE_IS_EMPTY(&wq)) { queue* h = QUEUE_HEAD(&wq); @@ -636,8 +636,8 @@ void httpModuleDestroy2(SHttpModule* http) { static int32_t taosSendHttpReportImplByChan(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen, EHttpCompFlag flag, int64_t chanId) { SHttpModule* load = NULL; - SHttpMsg *msg = NULL; - int32_t code = httpCreateMsg(server, uri, port, pCont, contLen, flag, chanId,&msg); + SHttpMsg* msg = NULL; + int32_t code = httpCreateMsg(server, uri, port, pCont, contLen, flag, chanId, &msg); if (code != 0) { goto _ERROR; } @@ -719,9 +719,8 @@ int64_t transInitHttpChanImpl() { goto _ERROR; } - http->asyncPool = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb); - if (http->asyncPool == NULL) { - code = terrno; + code = transAsyncPoolCreate(http->loop, 1, http, httpAsyncCb, &http->asyncPool); + if (code != 0) { goto _ERROR; } diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index c35f147fc5..f86c010828 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -27,18 +27,20 @@ int (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transRelease static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) { int32_t code = taosGetIpv4FromFqdn(localFqdn, ip); - if (code) { - terrno = TSDB_CODE_RPC_FQDN_ERROR; - return -1; + if (code != 0) { + return TSDB_CODE_RPC_FQDN_ERROR; } return 0; } void* rpcOpen(const SRpcInit* pInit) { - rpcInit(); + int32_t code = rpcInit(); + if (code != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } SRpcInfo* pRpc = taosMemoryCalloc(1, sizeof(SRpcInfo)); if (pRpc == NULL) { - return NULL; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); } if (pInit->label) { int len = strlen(pInit->label) > sizeof(pRpc->label) ? sizeof(pRpc->label) : strlen(pInit->label); @@ -84,10 +86,9 @@ void* rpcOpen(const SRpcInit* pInit) { uint32_t ip = 0; if (pInit->connType == TAOS_CONN_SERVER) { - if (transValidLocalFqdn(pInit->localFqdn, &ip) != 0) { - tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, terrstr()); - taosMemoryFree(pRpc); - return NULL; + if ((code = transValidLocalFqdn(pInit->localFqdn, &ip)) != 0) { + tError("invalid fqdn:%s, errmsg:%s", pInit->localFqdn, tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); } } @@ -105,14 +106,19 @@ void* rpcOpen(const SRpcInit* pInit) { (*taosInitHandle[pRpc->connType])(ip, pInit->localPort, pRpc->label, pRpc->numOfThreads, NULL, pRpc); if (pRpc->tcphandle == NULL) { - taosMemoryFree(pRpc); - return NULL; + tError("failed to init rpc handle"); + TAOS_CHECK_GOTO(terrno, NULL, _end); } int64_t refId = transAddExHandle(transGetInstMgt(), pRpc); transAcquireExHandle(transGetInstMgt(), refId); pRpc->refId = refId; return (void*)refId; +_end: + taosMemoryFree(pRpc); + terrno = code; + + return NULL; } void rpcClose(void* arg) { tInfo("start to close rpc"); @@ -186,7 +192,7 @@ int rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) { return transSetDefaultAddr(thandle, ip, fqdn); } // server only -void rpcSetIpWhite(void* thandle, void* arg) { transSetIpWhiteList(thandle, arg, NULL); } +int32_t rpcSetIpWhite(void* thandle, void* arg) { return transSetIpWhiteList(thandle, arg, NULL); } void* rpcAllocHandle() { return (void*)transAllocHandle(); } @@ -202,10 +208,8 @@ int32_t rpcCvtErrCode(int32_t code) { return code; } -int32_t rpcInit() { - transInit(); - return 0; -} +int32_t rpcInit() { return transInit(); } + void rpcCleanup(void) { transCleanup(); transHttpEnvDestroy(); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 19af63b24f..b51964083f 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -114,7 +114,7 @@ typedef struct SCliThrd { SDelayQueue* timeoutQueue; SDelayQueue* waitConnQueue; uint64_t nextTimeout; // next timeout - void* pTransInst; // + STrans* pTransInst; // int connCount; void (*destroyAhandleFp)(void* ahandle); @@ -180,12 +180,12 @@ static int32_t allocConnRef(SCliConn* conn, bool update); static int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg); -static SCliConn* cliCreateConn(SCliThrd* thrd); -static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); -static void cliDestroy(uv_handle_t* handle); -static void cliSend(SCliConn* pConn); -static void cliSendBatch(SCliConn* pConn); -static void cliDestroyConnMsgs(SCliConn* conn, bool destroy); +static int32_t cliCreateConn(SCliThrd* thrd, SCliConn** pCliConn); +static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); +static void cliDestroy(uv_handle_t* handle); +static void cliSend(SCliConn* pConn); +static void cliSendBatch(SCliConn* pConn); +static void cliDestroyConnMsgs(SCliConn* conn, bool destroy); static void doFreeTimeoutMsg(void* param); static int32_t cliPreCheckSessionLimitForMsg(SCliThrd* pThrd, char* addr, SCliMsg** pMsg); @@ -196,8 +196,8 @@ static FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr); static FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* resp); -static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ip); -static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn); +static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ipaddr); +static FORCE_INLINE int32_t cliUpdateFqdnCache(SHashObj* cache, char* fqdn); static FORCE_INLINE void cliMayUpdateFqdnCache(SHashObj* cache, char* dst); // process data read from server, add decompress etc later @@ -226,10 +226,9 @@ static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst); static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx); // thread obj -static SCliThrd* createThrdObj(void* trans); -static void destroyThrdObj(SCliThrd* pThrd); - -static void cliWalkCb(uv_handle_t* handle, void* arg); +static int32_t createThrdObj(void* trans, SCliThrd** pThrd); +static void destroyThrdObj(SCliThrd* pThrd); +static void cliWalkCb(uv_handle_t* handle, void* arg); #define CLI_RELEASE_UV(loop) \ do { \ @@ -714,10 +713,22 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) { } STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); + if (arg == NULL) { + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } arg->param1 = *pMsg; arg->param2 = pThrd; - (*pMsg)->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + SDelayTask* task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + if (task == NULL) { + taosMemoryFree(arg); + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } + (*pMsg)->ctx->task = task; tGTrace("%s msg %s delay to send, wait for avaiable connect", pTransInst->label, TMSG_INFO((*pMsg)->msg.msgType)); QUEUE_PUSH(&(list)->msgQ, &(*pMsg)->q); *pMsg = NULL; @@ -725,9 +736,23 @@ static SCliConn* getConnFromPool2(SCliThrd* pThrd, char* key, SCliMsg** pMsg) { // send msg in delay queue if (!(QUEUE_IS_EMPTY(&(list)->msgQ))) { STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); + if (arg == NULL) { + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } arg->param1 = *pMsg; arg->param2 = pThrd; - (*pMsg)->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + + SDelayTask* task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); + if (task == NULL) { + taosMemoryFree(arg); + doNotifyApp(*pMsg, pThrd, TSDB_CODE_OUT_OF_MEMORY); + *pMsg = NULL; + return NULL; + } + + (*pMsg)->ctx->task = task; tGTrace("%s msg %s delay to send, wait for avaiable connect", pTransInst->label, TMSG_INFO((*pMsg)->msg.msgType)); @@ -767,7 +792,11 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->status == ConnInPool) { return; } - allocConnRef(conn, true); + int32_t code = allocConnRef(conn, true); + if (code != 0) { + cliDestroyConn(conn, true); + return; + } SCliThrd* thrd = conn->hostThrd; if (conn->timer != NULL) { @@ -812,6 +841,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->list->size >= 10) { STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); + if (arg == NULL) return; arg->param1 = conn; arg->param2 = thrd; @@ -827,9 +857,12 @@ static int32_t allocConnRef(SCliConn* conn, bool update) { } SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + exh->refId = transAddExHandle(transGetRefMgt(), exh); - SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); - if (self != exh) { + if (exh->refId < 0) { taosMemoryFree(exh); return TSDB_CODE_REF_INVALID_ID; } @@ -839,8 +872,14 @@ static int32_t allocConnRef(SCliConn* conn, bool update) { exh->handle = conn; exh->pThrd = conn->hostThrd; + SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (self != exh) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + conn->refId = exh->refId; - if (conn->refId == -1) { + if (conn->refId < 0) { taosMemoryFree(exh); } return 0; @@ -871,7 +910,11 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) { static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SCliConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; - transAllocBuffer(pBuf, buf); + int32_t code = transAllocBuffer(pBuf, buf); + if (code < 0) { + tError("conn %p failed to alloc buffer, since %s", conn, tstrerror(code)); + // cliDestroyConn(conn, true); + } } static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { // impl later @@ -909,16 +952,35 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { } } -static SCliConn* cliCreateConn(SCliThrd* pThrd) { +static int32_t cliCreateConn(SCliThrd* pThrd, SCliConn** pCliConn) { + int32_t code = 0; SCliConn* conn = taosMemoryCalloc(1, sizeof(SCliConn)); + if (conn == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + // read/write stream handle conn->stream = (uv_stream_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); - uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream)); + if (conn->stream == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(code, NULL, _failed); + } + + code = uv_tcp_init(pThrd->loop, (uv_tcp_t*)(conn->stream)); + if (code != 0) { + tError("failed to init tcp handle, code:%d, %s", code, uv_strerror(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + TAOS_CHECK_GOTO(code, NULL, _failed); + } conn->stream->data = conn; uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL; if (timer == NULL) { timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + if (timer == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _failed); + } + tDebug("no available timer, create a timer %p", timer); uv_timer_init(pThrd->loop, timer); } @@ -927,8 +989,11 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) { conn->timer = timer; conn->connReq.data = conn; transReqQueueInit(&conn->wreqQueue); - transQueueInit(&conn->cliMsgs, NULL); - transInitBuffer(&conn->readBuf); + + TAOS_CHECK_GOTO(transQueueInit(&conn->cliMsgs, NULL), NULL, _failed); + + TAOS_CHECK_GOTO(transInitBuffer(&conn->readBuf), NULL, _failed); + QUEUE_INIT(&conn->q); conn->hostThrd = pThrd; conn->status = ConnNormal; @@ -936,9 +1001,20 @@ static SCliConn* cliCreateConn(SCliThrd* pThrd) { transRefCliHandle(conn); atomic_add_fetch_32(&pThrd->connCount, 1); - allocConnRef(conn, false); - return conn; + TAOS_CHECK_GOTO(allocConnRef(conn, false), NULL, _failed); + + *pCliConn = conn; + return code; +_failed: + if (conn) { + taosMemoryFree(conn->stream); + transReqQueueClear(&conn->wreqQueue); + transDestroyBuffer(&conn->readBuf); + transQueueDestroy(&conn->cliMsgs); + } + taosMemoryFree(conn); + return code; } static void cliDestroyConn(SCliConn* conn, bool clear) { SCliThrd* pThrd = conn->hostThrd; @@ -1225,6 +1301,7 @@ static void cliDestroyBatch(SCliBatch* pBatch) { taosMemoryFree(pBatch); } static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { + int32_t code = 0; if (pThrd->quit == true) { cliDestroyBatch(pBatch); return; @@ -1249,22 +1326,33 @@ static void cliHandleBatchReq(SCliBatch* pBatch, SCliThrd* pThrd) { return; } if (conn == NULL) { - conn = cliCreateConn(pThrd); + code = cliCreateConn(pThrd, &conn); + if (code != 0) { + tError("%s failed to send batch msg, batch size:%d, msgLen: %d, conn limit:%d, reason:%s", pTransInst->label, + pBatch->wLen, pBatch->batchSize, pTransInst->connLimitNum, tstrerror(code)); + cliDestroyBatch(pBatch); + return; + } + conn->pBatch = pBatch; conn->dstAddr = taosStrdup(pList->dst); + if (conn->dstAddr == NULL) { + tError("%s conn %p failed to send batch msg, reason:%s", transLabel(pTransInst), conn, + tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + cliHandleFastFail(conn, -1); + return; + } uint32_t ipaddr = 0; - int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, pList->ip, &ipaddr); - if (code) { + if ((code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, pList->ip, &ipaddr)) != 0) { uv_timer_stop(conn->timer); conn->timer->data = NULL; taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; - - cliHandleFastFail(conn, terrno); - terrno = 0; + cliHandleFastFail(conn, code); return; } + struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = ipaddr; @@ -1553,37 +1641,45 @@ FORCE_INLINE bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) { FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) { if (pMsg == NULL) return -1; - memset(pResp, 0, sizeof(STransMsg)); + // memset(pResp, 0, sizeof(STransMsg)); - pResp->code = TSDB_CODE_RPC_BROKEN_LINK; + if (pResp->code == 0) { + pResp->code = TSDB_CODE_RPC_BROKEN_LINK; + } pResp->msgType = pMsg->msg.msgType + 1; pResp->info.ahandle = pMsg->ctx ? pMsg->ctx->ahandle : NULL; pResp->info.traceId = pMsg->msg.info.traceId; return 0; } + static FORCE_INLINE int32_t cliGetIpFromFqdnCache(SHashObj* cache, char* fqdn, uint32_t* ip) { + int32_t code = 0; + uint32_t addr = 0; size_t len = strlen(fqdn); uint32_t* v = taosHashGet(cache, fqdn, len); if (v == NULL) { - int32_t code = taosGetIpv4FromFqdn(fqdn, ip); - if (code) { - tError("failed to get ip from fqdn:%s since %s", fqdn, terrstr()); + code = taosGetIpv4FromFqdn(fqdn, &addr); + if (code != 0) { + code = TSDB_CODE_RPC_FQDN_ERROR; + tError("failed to get ip from fqdn:%s since %s", fqdn, tstrerror(code)); return code; } - taosHashPut(cache, fqdn, len, ip, sizeof(*ip)); + if ((code = taosHashPut(cache, fqdn, len, &addr, sizeof(addr)) != 0)) { + return code; + } + *ip = addr; } else { *ip = *v; } - - return TSDB_CODE_SUCCESS; + return 0; } -static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { +static FORCE_INLINE int32_t cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { // impl later uint32_t addr = 0; - int32_t code = taosGetIpv4FromFqdn(fqdn, &addr); - if (TSDB_CODE_SUCCESS == code) { + int32_t code = taosGetIpv4FromFqdn(fqdn, &addr); + if (code == 0) { size_t len = strlen(fqdn); uint32_t* v = taosHashGet(cache, fqdn, len); if (addr != *v) { @@ -1591,10 +1687,12 @@ static FORCE_INLINE void cliUpdateFqdnCache(SHashObj* cache, char* fqdn) { tinet_ntoa(old, *v); tinet_ntoa(new, addr); tWarn("update ip of fqdn:%s, old: %s, new: %s", fqdn, old, new); - taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr)); + code = taosHashPut(cache, fqdn, strlen(fqdn), &addr, sizeof(addr)); } + } else { + code = TSDB_CODE_RPC_FQDN_ERROR; // TSDB_CODE_RPC_INVALID_FQDN; } - return; + return code; } static void cliMayUpdateFqdnCache(SHashObj* cache, char* dst) { @@ -1623,7 +1721,9 @@ static void doFreeTimeoutMsg(void* param) { doNotifyApp(pMsg, pThrd, code); taosMemoryFree(arg); } + void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { + int32_t code = 0; STrans* pTransInst = pThrd->pTransInst; cliMayCvtFqdnToIp(&pMsg->ctx->epSet, &pThrd->cvtAddr); @@ -1641,7 +1741,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { SCliConn* conn = cliGetConn(&pMsg, pThrd, &ignore, addr); if (ignore == true) { // persist conn already release by server - STransMsg resp; + STransMsg resp = {0}; cliBuildExceptResp(pMsg, &resp); // refactorr later resp.info.cliVer = pTransInst->compatibilityVer; @@ -1662,7 +1762,19 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { transQueuePush(&conn->cliMsgs, pMsg); cliSend(conn); } else { - conn = cliCreateConn(pThrd); + code = cliCreateConn(pThrd, &conn); + if (code != 0) { + tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code)); + STransMsg resp = {.code = code}; + cliBuildExceptResp(pMsg, &resp); + + resp.info.cliVer = pTransInst->compatibilityVer; + if (pMsg->type != Release) { + pTransInst->cfp(pTransInst->parent, &resp, NULL); + } + destroyCmsg(pMsg); + return; + } int64_t refId = (int64_t)pMsg->msg.info.handle; if (refId != 0) specifyConnRef(conn, true, refId); @@ -1672,16 +1784,15 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { conn->dstAddr = taosStrdup(addr); - uint32_t ipaddr = 0; - int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, fqdn, &ipaddr); - if (code) { + uint32_t ipaddr; + int32_t code = cliGetIpFromFqdnCache(pThrd->fqdn2ipCache, fqdn, &ipaddr); + if (code != 0) { uv_timer_stop(conn->timer); conn->timer->data = NULL; taosArrayPush(pThrd->timerList, &conn->timer); conn->timer = NULL; - cliHandleExcept(conn, terrno); - terrno = 0; + cliHandleExcept(conn, code); return; } @@ -1699,12 +1810,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { errno = 0; return; } + int ret = uv_tcp_open((uv_tcp_t*)conn->stream, fd); if (ret != 0) { tGError("%s conn %p failed to set stream, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); cliHandleExcept(conn, -1); return; } + ret = transSetConnOption((uv_tcp_t*)conn->stream, tsKeepAliveIdle); if (ret != 0) { tGError("%s conn %p failed to set socket opt, reason:%s", transLabel(pTransInst), conn, uv_err_name(ret)); @@ -1981,12 +2094,12 @@ bool cliRecvReleaseReq(SCliConn* conn, STransMsgHead* pHead) { } static void* cliWorkThread(void* arg) { + char threadName[TSDB_LABEL_LEN] = {0}; + SCliThrd* pThrd = (SCliThrd*)arg; pThrd->pid = taosGetSelfPthreadId(); - char threadName[TSDB_LABEL_LEN] = {0}; - STrans* pInst = pThrd->pTransInst; - strtolower(threadName, pInst->label); + strtolower(threadName, pThrd->pTransInst->label); setThreadName(threadName); uv_run(pThrd->loop, UV_RUN_DEFAULT); @@ -1996,22 +2109,32 @@ static void* cliWorkThread(void* arg) { } void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { + int32_t code = 0; SCliObj* cli = taosMemoryCalloc(1, sizeof(SCliObj)); + if (cli == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } STrans* pTransInst = shandle; memcpy(cli->label, label, TSDB_LABEL_LEN); cli->numOfThreads = numOfThreads; + cli->pThreadObj = (SCliThrd**)taosMemoryCalloc(cli->numOfThreads, sizeof(SCliThrd*)); + if (cli->pThreadObj == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _err); + } for (int i = 0; i < cli->numOfThreads; i++) { - SCliThrd* pThrd = createThrdObj(shandle); - if (pThrd == NULL) { + SCliThrd* pThrd = NULL; + code = createThrdObj(shandle, &pThrd); + if (code != 0) { goto _err; } int err = taosThreadCreate(&pThrd->thread, NULL, cliWorkThread, (void*)(pThrd)); if (err != 0) { - goto _err; + code = TAOS_SYSTEM_ERROR(errno); + TAOS_CHECK_GOTO(code, NULL, _err); } else { tDebug("success to create tranport-cli thread:%d", i); } @@ -2020,8 +2143,11 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, return cli; _err: - taosMemoryFree(cli->pThreadObj); - taosMemoryFree(cli); + if (cli) { + taosMemoryFree(cli->pThreadObj); + taosMemoryFree(cli); + } + terrno = code; return NULL; } @@ -2037,11 +2163,9 @@ static FORCE_INLINE void destroyCmsg(void* arg) { taosMemoryFree(pMsg); } static FORCE_INLINE void destroyCmsgWrapper(void* arg, void* param) { - SCliMsg* pMsg = arg; - if (pMsg == NULL) { - return; - } + if (arg == NULL) return; + SCliMsg* pMsg = arg; SCliThrd* pThrd = param; if (pMsg->msg.info.notFreeAhandle == 0 && pThrd != NULL) { if (pThrd->destroyAhandleFp) (*pThrd->destroyAhandleFp)(pMsg->msg.info.ahandle); @@ -2064,67 +2188,124 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) { taosMemoryFree(pMsg); } -static SCliThrd* createThrdObj(void* trans) { +static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) { + int32_t code = 0; STrans* pTransInst = trans; SCliThrd* pThrd = (SCliThrd*)taosMemoryCalloc(1, sizeof(SCliThrd)); + if (pThrd == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } QUEUE_INIT(&pThrd->msg); taosThreadMutexInit(&pThrd->msgMtx, NULL); pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); - int err = uv_loop_init(pThrd->loop); - if (err != 0) { - tError("failed to init uv_loop, reason:%s", uv_err_name(err)); - taosMemoryFree(pThrd->loop); - taosThreadMutexDestroy(&pThrd->msgMtx); - taosMemoryFree(pThrd); - return NULL; + if (pThrd->loop == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); } - int32_t nSync = pTransInst->supportBatch ? 4 : 8; - pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, nSync, pThrd, cliAsyncCb); - if (pThrd->asyncPool == NULL) { - tError("failed to init async pool"); - uv_loop_close(pThrd->loop); - taosMemoryFree(pThrd->loop); - taosThreadMutexDestroy(&pThrd->msgMtx); - taosMemoryFree(pThrd); - return NULL; + code = uv_loop_init(pThrd->loop); + if (code != 0) { + tError("failed to init uv_loop, reason:%s", uv_err_name(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } + + int32_t nSync = pTransInst->supportBatch ? 4 : 8; + code = transAsyncPoolCreate(pThrd->loop, nSync, pThrd, cliAsyncCb, &pThrd->asyncPool); + if (code != 0) { + tError("failed to init async pool since:%s", tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); } pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); - uv_prepare_init(pThrd->loop, pThrd->prepare); + if (pThrd->prepare == NULL) { + tError("failed to create prepre since:%s", tstrerror(code)); + TAOS_CHECK_GOTO(code, NULL, _end); + } + + code = uv_prepare_init(pThrd->loop, pThrd->prepare); + if (code != 0) { + tError("failed to create prepre since:%s", uv_err_name(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } pThrd->prepare->data = pThrd; - // uv_prepare_start(pThrd->prepare, cliPrepareCb); int32_t timerSize = 64; pThrd->timerList = taosArrayInit(timerSize, sizeof(void*)); + if (pThrd->timerList == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + for (int i = 0; i < timerSize; i++) { uv_timer_t* timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + if (timer == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } uv_timer_init(pThrd->loop, timer); taosArrayPush(pThrd->timerList, &timer); } pThrd->pool = createConnPool(4); - transDQCreate(pThrd->loop, &pThrd->delayQueue); + if (pThrd->pool == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + if ((code = transDQCreate(pThrd->loop, &pThrd->delayQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } - transDQCreate(pThrd->loop, &pThrd->timeoutQueue); + if ((code = transDQCreate(pThrd->loop, &pThrd->timeoutQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } - transDQCreate(pThrd->loop, &pThrd->waitConnQueue); - - pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); - pThrd->pTransInst = trans; + if ((code = transDQCreate(pThrd->loop, &pThrd->waitConnQueue)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } pThrd->destroyAhandleFp = pTransInst->destroyFp; pThrd->fqdn2ipCache = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->fqdn2ipCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } pThrd->failFastCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->failFastCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } pThrd->batchCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (pThrd->batchCache == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + pThrd->nextTimeout = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); + pThrd->pTransInst = trans; pThrd->quit = false; - return pThrd; + *ppThrd = pThrd; + return code; + +_end: + if (pThrd) { + uv_loop_close(pThrd->loop); + taosMemoryFree(pThrd->loop); + taosMemoryFree(pThrd->prepare); + taosThreadMutexDestroy(&pThrd->msgMtx); + transAsyncPoolDestroy(pThrd->asyncPool); + for (int i = 0; i < taosArrayGetSize(pThrd->timerList); i++) { + uv_timer_t* timer = taosArrayGetP(pThrd->timerList, i); + taosMemoryFree(timer); + } + taosArrayDestroy(pThrd->timerList); + taosMemoryFree(pThrd->prepare); + taosHashCleanup(pThrd->fqdn2ipCache); + taosHashCleanup(pThrd->failFastCache); + taosHashCleanup(pThrd->batchCache); + + taosMemoryFree(pThrd); + } + return code; } static void destroyThrdObj(SCliThrd* pThrd) { if (pThrd == NULL) { @@ -2177,12 +2358,23 @@ static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx) { taosMemoryFree(ctx); } -void cliSendQuit(SCliThrd* thrd) { +int32_t cliSendQuit(SCliThrd* thrd) { // cli can stop gracefully + int32_t code = 0; SCliMsg* msg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (msg == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + msg->type = Quit; - transAsyncSend(thrd->asyncPool, &msg->q); + if ((code = transAsyncSend(thrd->asyncPool, &msg->q)) != 0) { + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + taosMemoryFree(msg); + return code; + } + atomic_store_8(&thrd->asyncPool->stop, 1); + return 0; } void cliWalkCb(uv_handle_t* handle, void* arg) { if (!uv_is_closing(handle)) { @@ -2506,9 +2698,14 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { } void transCloseClient(void* arg) { + int32_t code = 0; SCliObj* cli = arg; for (int i = 0; i < cli->numOfThreads; i++) { - cliSendQuit(cli->pThreadObj[i]); + code = cliSendQuit(cli->pThreadObj[i]); + if (code != 0) { + tError("failed to send quit to thread:%d, reason:%s", i, tstrerror(code)); + } + destroyThrdObj(cli->pThreadObj[i]); } taosMemoryFree(cli->pThreadObj); @@ -2563,9 +2760,7 @@ SCliThrd* transGetWorkThrd(STrans* trans, int64_t handle) { return pThrd; } int transReleaseCliHandle(void* handle) { - int idx = -1; - bool valid = false; - + int32_t code = 0; SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle); if (pThrd == NULL) { return TSDB_CODE_RPC_BROKEN_LINK; @@ -2575,9 +2770,17 @@ int transReleaseCliHandle(void* handle) { TRACE_SET_MSGID(&tmsg.info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCtx->ahandle = tmsg.info.ahandle; SCliMsg* cmsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cmsg == NULL) { + taosMemoryFree(pCtx); + return TSDB_CODE_OUT_OF_MEMORY; + } cmsg->msg = tmsg; cmsg->st = taosGetTimestampUs(); cmsg->type = Release; @@ -2586,15 +2789,20 @@ int transReleaseCliHandle(void* handle) { STraceId* trace = &tmsg.info.traceId; tGDebug("send release request at thread:%08" PRId64 ", malloc memory:%p", pThrd->pid, cmsg); - if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &cmsg->q)) != 0) { destroyCmsg(cmsg); - return TSDB_CODE_RPC_BROKEN_LINK; + return code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code; } - return 0; + return code; } -static SCliMsg* transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) { + +static int32_t transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx, SCliMsg** pCliMsg) { TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); @@ -2604,13 +2812,20 @@ static SCliMsg* transInitMsg(void* shandle, const SEpSet* pEpSet, STransMsg* pRe if (ctx != NULL) pCtx->appCtx = *ctx; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + return TSDB_CODE_OUT_OF_MEMORY; + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); cliMsg->type = Normal; cliMsg->refId = (int64_t)shandle; QUEUE_INIT(&cliMsg->seqq); - return cliMsg; + *pCliMsg = cliMsg; + + return 0; } int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* ctx) { @@ -2619,7 +2834,7 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran transFreeMsg(pReq->pCont); return TSDB_CODE_RPC_BROKEN_LINK; } - + int32_t code = 0; int64_t handle = (int64_t)pReq->info.handle; SCliThrd* pThrd = transGetWorkThrd(pTransInst, handle); if (pThrd == NULL) { @@ -2632,7 +2847,10 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran if (exh != NULL) { taosWLockLatch(&exh->latch); if (exh->handle == NULL && exh->inited != 0) { - SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx); + SCliMsg* pCliMsg = NULL; + code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg); + ASSERT(code == 0); + QUEUE_PUSH(&exh->q, &pCliMsg->seqq); taosWUnLockLatch(&exh->latch); tDebug("msg refId: %" PRId64 "", handle); @@ -2644,43 +2862,65 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran transReleaseExHandle(transGetRefMgt(), handle); } } - SCliMsg* pCliMsg = transInitMsg(shandle, pEpSet, pReq, ctx); + + SCliMsg* pCliMsg = NULL; + code = transInitMsg(shandle, pEpSet, pReq, ctx, &pCliMsg); + if (code != 0) { + transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return code; + } STraceId* trace = &pReq->info.traceId; tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(pEpSet), EPSET_GET_INUSE_PORT(pEpSet), pReq->info.ahandle); - if (0 != transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) { + if ((code = transAsyncSend(pThrd->asyncPool, &(pCliMsg->q))) != 0) { destroyCmsg(pCliMsg); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + return (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); } transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); return 0; } int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp) { - STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); - STransMsg* pTransRsp = taosMemoryCalloc(1, sizeof(STransMsg)); + STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { transFreeMsg(pReq->pCont); - taosMemoryFree(pTransRsp); return TSDB_CODE_RPC_BROKEN_LINK; } + int32_t code = 0; + + STransMsg* pTransRsp = taosMemoryCalloc(1, sizeof(STransMsg)); + if (pTransRsp == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); if (pThrd == NULL) { - transFreeMsg(pReq->pCont); - taosMemoryFree(pTransRsp); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(TSDB_CODE_RPC_BROKEN_LINK, NULL, _RETURN1); } tsem_t* sem = taosMemoryCalloc(1, sizeof(tsem_t)); - tsem_init(sem, 0, 0); + if (sem == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + + code = tsem_init(sem, 0, 0); + if (code != 0) { + taosMemoryFree(sem); + code = TAOS_SYSTEM_ERROR(errno); + TAOS_CHECK_GOTO(code, NULL, _RETURN1); + } TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + tsem_destroy(sem); + taosMemoryFree(sem); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); pCtx->ahandle = pReq->info.ahandle; @@ -2689,6 +2929,13 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs pCtx->pRsp = pTransRsp; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + tsem_destroy(sem); + taosMemoryFree(sem); + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN1); + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); @@ -2699,11 +2946,10 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); - if (ret != 0) { + code = transAsyncSend(pThrd->asyncPool, &cliMsg->q); + if (code != 0) { destroyCmsg(cliMsg); - ret = TSDB_CODE_RPC_BROKEN_LINK; - goto _RETURN; + TAOS_CHECK_GOTO((code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code), NULL, _RETURN); } tsem_wait(sem); @@ -2714,13 +2960,28 @@ _RETURN: taosMemoryFree(sem); transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); taosMemoryFree(pTransRsp); - return ret; + return code; +_RETURN1: + transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + taosMemoryFree(pTransRsp); + taosMemoryFree(pReq->pCont); + return code; } -int64_t transCreateSyncMsg(STransMsg* pTransMsg) { +int32_t transCreateSyncMsg(STransMsg* pTransMsg, int64_t* refId) { + int32_t code = 0; tsem2_t* sem = taosMemoryCalloc(1, sizeof(tsem2_t)); - tsem2_init(sem, 0, 0); + if (sem == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if (tsem2_init(sem, 0, 0) != 0) { + TAOS_CHECK_GOTO(TAOS_SYSTEM_ERROR(errno), NULL, _EXIT); + } STransSyncMsg* pSyncMsg = taosMemoryCalloc(1, sizeof(STransSyncMsg)); + if (pSyncMsg == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _EXIT); + } taosInitRWLatch(&pSyncMsg->latch); pSyncMsg->inited = 0; @@ -2728,39 +2989,69 @@ int64_t transCreateSyncMsg(STransMsg* pTransMsg) { pSyncMsg->pSem = sem; pSyncMsg->hasEpSet = 0; - return taosAddRef(transGetSyncMsgMgt(), pSyncMsg); + int64_t id = taosAddRef(transGetSyncMsgMgt(), pSyncMsg); + if (id < 0) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _EXIT); + } else { + *refId = id; + } + return 0; + +_EXIT: + tsem2_destroy(sem); + taosMemoryFree(sem); + taosMemoryFree(pSyncMsg); + return code; } int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp, int8_t* epUpdated, int32_t timeoutMs) { - STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); - STransMsg* pTransMsg = taosMemoryCalloc(1, sizeof(STransMsg)); + int32_t code = 0; + STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)shandle); if (pTransInst == NULL) { transFreeMsg(pReq->pCont); - taosMemoryFree(pTransMsg); return TSDB_CODE_RPC_BROKEN_LINK; } + STransMsg* pTransMsg = taosMemoryCalloc(1, sizeof(STransMsg)); + if (pTransMsg == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle); if (pThrd == NULL) { - transFreeMsg(pReq->pCont); - taosMemoryFree(pTransMsg); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(TSDB_CODE_RPC_BROKEN_LINK, NULL, _RETURN2); } TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64()); STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + epsetAssign(&pCtx->epSet, pEpSet); epsetAssign(&pCtx->origEpSet, pEpSet); pCtx->ahandle = pReq->info.ahandle; pCtx->msgType = pReq->msgType; - pCtx->syncMsgRef = transCreateSyncMsg(pTransMsg); + + if ((code = transCreateSyncMsg(pTransMsg, &pCtx->syncMsgRef)) != 0) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(code, NULL, _RETURN2); + } int64_t ref = pCtx->syncMsgRef; STransSyncMsg* pSyncMsg = taosAcquireRef(transGetSyncMsgMgt(), ref); + if (pSyncMsg == NULL) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _RETURN2); + } SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _RETURN2); + } + cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); @@ -2771,17 +3062,17 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr tGDebug("%s send request at thread:%08" PRId64 ", dst:%s:%d, app:%p", transLabel(pTransInst), pThrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); - int ret = transAsyncSend(pThrd->asyncPool, &cliMsg->q); - if (ret != 0) { + code = transAsyncSend(pThrd->asyncPool, &cliMsg->q); + if (code != 0) { destroyCmsg(cliMsg); - ret = TSDB_CODE_RPC_BROKEN_LINK; + TAOS_CHECK_GOTO(code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code, NULL, _RETURN); goto _RETURN; } - ret = tsem2_timewait(pSyncMsg->pSem, timeoutMs); - if (ret < 0) { + code = tsem2_timewait(pSyncMsg->pSem, timeoutMs); + if (code < 0) { pRsp->code = TSDB_CODE_TIMEOUT_ERROR; - ret = TSDB_CODE_TIMEOUT_ERROR; + code = TSDB_CODE_TIMEOUT_ERROR; } else { memcpy(pRsp, pSyncMsg->pRsp, sizeof(STransMsg)); pSyncMsg->pRsp->pCont = NULL; @@ -2789,13 +3080,18 @@ int transSendRecvWithTimeout(void* shandle, SEpSet* pEpSet, STransMsg* pReq, STr epsetAssign(pEpSet, &pSyncMsg->epSet); *epUpdated = 1; } - ret = 0; + code = 0; } _RETURN: transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); taosReleaseRef(transGetSyncMsgMgt(), ref); taosRemoveRef(transGetSyncMsgMgt(), ref); - return ret; + return code; +_RETURN2: + transFreeMsg(pReq->pCont); + taosMemoryFree(pTransMsg); + transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + return code; } /* * @@ -2812,11 +3108,25 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { tstrncpy(cvtAddr.fqdn, fqdn, sizeof(cvtAddr.fqdn)); cvtAddr.cvt = true; } - for (int i = 0; i < pTransInst->numOfThreads; i++) { + + int32_t code = 0; + int8_t i = 0; + for (i = 0; i < pTransInst->numOfThreads; i++) { STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx)); + if (pCtx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pCtx->cvtAddr = cvtAddr; SCliMsg* cliMsg = taosMemoryCalloc(1, sizeof(SCliMsg)); + if (cliMsg == NULL) { + taosMemoryFree(pCtx); + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + cliMsg->ctx = pCtx; cliMsg->type = Update; cliMsg->refId = (int64_t)shandle; @@ -2824,21 +3134,30 @@ int transSetDefaultAddr(void* shandle, const char* ip, const char* fqdn) { SCliThrd* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[i]; tDebug("%s update epset at thread:%08" PRId64, pTransInst->label, thrd->pid); - if (transAsyncSend(thrd->asyncPool, &(cliMsg->q)) != 0) { + if ((code = transAsyncSend(thrd->asyncPool, &(cliMsg->q))) != 0) { destroyCmsg(cliMsg); - transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + break; } } + transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); - return 0; + return code; } int64_t transAllocHandle() { SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + SExHandle* self = transAcquireExHandle(transGetRefMgt(), exh->refId); - ASSERT(exh == self); if (exh != self) { taosMemoryFree(exh); return TSDB_CODE_REF_INVALID_ID; @@ -2847,6 +3166,5 @@ int64_t transAllocHandle() { QUEUE_INIT(&exh->q); taosInitRWLatch(&exh->latch); tDebug("pre alloc refId %" PRId64 "", exh->refId); - return exh->refId; } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index b9223e7b39..aa6b377423 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -67,7 +67,11 @@ int32_t transDecompressMsg(char** msg, int32_t len) { STransCompMsg* pComp = (STransCompMsg*)pCont; int32_t oriLen = htonl(pComp->contLen); - char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead)); + char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead)); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + STransMsgHead* pNewHead = (STransMsgHead*)buf; int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), (char*)pNewHead->content, len - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen); @@ -78,7 +82,7 @@ int32_t transDecompressMsg(char** msg, int32_t len) { taosMemoryFree(pHead); *msg = buf; if (decompLen != oriLen) { - return -1; + return TSDB_CODE_INVALID_MSG; } return 0; } @@ -98,26 +102,33 @@ int transSockInfo2Str(struct sockaddr* sockname, char* dst) { sprintf(dst, "%s:%d", buf, ntohs(addr.sin_port)); return r; } -int transInitBuffer(SConnBuffer* buf) { - buf->cap = BUFFER_CAP; +int32_t transInitBuffer(SConnBuffer* buf) { buf->buf = taosMemoryCalloc(1, BUFFER_CAP); + if (buf->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + buf->cap = BUFFER_CAP; buf->left = -1; buf->len = 0; buf->total = 0; buf->invalid = 0; return 0; } -int transDestroyBuffer(SConnBuffer* p) { +int32_t transDestroyBuffer(SConnBuffer* p) { taosMemoryFree(p->buf); p->buf = NULL; return 0; } -int transClearBuffer(SConnBuffer* buf) { +int32_t transClearBuffer(SConnBuffer* buf) { SConnBuffer* p = buf; if (p->cap > BUFFER_CAP) { p->cap = BUFFER_CAP; p->buf = taosMemoryRealloc(p->buf, BUFFER_CAP); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } p->left = -1; p->len = 0; @@ -126,27 +137,31 @@ int transClearBuffer(SConnBuffer* buf) { return 0; } -int transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) { +int32_t transDumpFromBuffer(SConnBuffer* connBuf, char** buf, int8_t resetBuf) { static const int HEADSIZE = sizeof(STransMsgHead); - - SConnBuffer* p = connBuf; + int32_t code = 0; + SConnBuffer* p = connBuf; if (p->left != 0 || p->total <= 0) { - return -1; + return TSDB_CODE_INVALID_MSG; } int total = p->total; if (total >= HEADSIZE && !p->invalid) { *buf = taosMemoryCalloc(1, total); + if (*buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } memcpy(*buf, p->buf, total); - if (transResetBuffer(connBuf, resetBuf) < 0) { - return -1; + if ((code = transResetBuffer(connBuf, resetBuf)) < 0) { + return code; } } else { total = -1; + return TSDB_CODE_INVALID_MSG; } return total; } -int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { +int32_t transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { SConnBuffer* p = connBuf; if (p->total < p->len) { int left = p->len - p->total; @@ -162,15 +177,18 @@ int transResetBuffer(SConnBuffer* connBuf, int8_t resetBuf) { if (resetBuf) { p->cap = BUFFER_CAP; p->buf = taosMemoryRealloc(p->buf, p->cap); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } } } } else { ASSERTS(0, "invalid read from sock buf"); - return -1; + return TSDB_CODE_INVALID_MSG; } return 0; } -int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { +int32_t transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { /* * formate of data buffer: * |<--------------------------data from socket------------------------------->| @@ -187,6 +205,9 @@ int transAllocBuffer(SConnBuffer* connBuf, uv_buf_t* uvBuf) { } else { p->cap = p->left + p->len; p->buf = taosMemoryRealloc(p->buf, p->cap); + if (p->buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } uvBuf->base = p->buf + p->len; uvBuf->len = p->left; } @@ -222,19 +243,19 @@ int transSetConnOption(uv_tcp_t* stream, int keepalive) { // int ret = uv_tcp_keepalive(stream, 5, 60); } -SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) { +int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAsyncPool** pPool) { SAsyncPool* pool = taosMemoryCalloc(1, sizeof(SAsyncPool)); if (pool == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; + // return NULL; } + int32_t code = 0; pool->nAsync = sz; pool->asyncs = taosMemoryCalloc(1, sizeof(uv_async_t) * pool->nAsync); if (pool->asyncs == NULL) { taosMemoryFree(pool); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + return TSDB_CODE_OUT_OF_MEMORY; } int i = 0, err = 0; @@ -243,7 +264,7 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) SAsyncItem* item = taosMemoryCalloc(1, sizeof(SAsyncItem)); if (item == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; break; } item->pThrd = arg; @@ -254,7 +275,7 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) err = uv_async_init(loop, async, cb); if (err != 0) { tError("failed to init async, reason:%s", uv_err_name(err)); - terrno = TSDB_CODE_THIRDPARTY_ERROR; + code = TSDB_CODE_THIRDPARTY_ERROR; break; } } @@ -264,10 +285,14 @@ SAsyncPool* transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb) pool = NULL; } - return pool; + *pPool = pool; + return 0; + // return pool; } void transAsyncPoolDestroy(SAsyncPool* pool) { + if (pool == NULL) return; + for (int i = 0; i < pool->nAsync; i++) { uv_async_t* async = &(pool->asyncs[i]); SAsyncItem* item = async->data; @@ -289,7 +314,7 @@ bool transAsyncPoolIsEmpty(SAsyncPool* pool) { } int transAsyncSend(SAsyncPool* pool, queue* q) { if (atomic_load_8(&pool->stop) == 1) { - return -1; + return TSDB_CODE_RPC_ASYNC_MODULE_QUIT; } int idx = pool->index % pool->nAsync; @@ -303,7 +328,12 @@ int transAsyncSend(SAsyncPool* pool, queue* q) { taosThreadMutexLock(&item->mtx); QUEUE_PUSH(&item->qmsg, q); taosThreadMutexUnlock(&item->mtx); - return uv_async_send(async); + int ret = uv_async_send(async); + if (ret != 0) { + tError("failed to send async,reason:%s", uv_err_name(ret)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + return 0; } void transCtxInit(STransCtx* ctx) { @@ -408,9 +438,14 @@ void transReqQueueClear(queue* q) { } } -void transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { +int32_t transQueueInit(STransQueue* queue, void (*freeFunc)(const void* arg)) { queue->q = taosArrayInit(2, sizeof(void*)); queue->freeFunc = (void (*)(const void*))freeFunc; + + if (queue->q == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + return 0; } bool transQueuePush(STransQueue* queue, void* arg) { if (queue->q == NULL) { @@ -513,20 +548,44 @@ static void transDQTimeout(uv_timer_t* timer) { uv_timer_start(queue->timer, transDQTimeout, timeout, 0); } } -int transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { - uv_timer_t* timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); - uv_timer_init(loop, timer); +int32_t transDQCreate(uv_loop_t* loop, SDelayQueue** queue) { + int32_t code = 0; + Heap* heap = NULL; + uv_timer_t* timer = NULL; + SDelayQueue* q = NULL; - Heap* heap = heapCreate(timeCompare); + timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + if (timer == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - SDelayQueue* q = taosMemoryCalloc(1, sizeof(SDelayQueue)); + heap = heapCreate(timeCompare); + if (heap == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1); + } + + q = taosMemoryCalloc(1, sizeof(SDelayQueue)); + if (q == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _return1); + } q->heap = heap; q->timer = timer; q->loop = loop; q->timer->data = q; + int err = uv_timer_init(loop, timer); + if (err != 0) { + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _return1); + } + *queue = q; return 0; + +_return1: + taosMemoryFree(timer); + heapDestroy(heap); + taosMemoryFree(q); + return TSDB_CODE_OUT_OF_MEMORY; } void transDQDestroy(SDelayQueue* queue, void (*freeFunc)(void* arg)) { @@ -578,6 +637,10 @@ void transDQCancel(SDelayQueue* queue, SDelayTask* task) { SDelayTask* transDQSched(SDelayQueue* queue, void (*func)(void* arg), void* arg, uint64_t timeoutMs) { uint64_t now = taosGetTimestampMs(); SDelayTask* task = taosMemoryCalloc(1, sizeof(SDelayTask)); + if (task == NULL) { + return NULL; + } + task->func = func; task->arg = arg; task->execTime = now + timeoutMs; @@ -648,9 +711,13 @@ static void transDestroyEnv() { transCloseRefMgt(transSyncMsgMgt); } -void transInit() { +int32_t transInit() { // init env - taosThreadOnce(&transModuleInit, transInitEnv); + int32_t code = taosThreadOnce(&transModuleInit, transInitEnv); + if (code != 0) { + code = TAOS_SYSTEM_ERROR(errno); + } + return code; } int32_t transGetRefMgt() { return refMgt; } @@ -709,29 +776,6 @@ void transDestroySyncMsg(void* msg) { taosMemoryFree(pSyncMsg); } -// void subnetIp2int(const char* const ip_addr, uint8_t* dst) { -// char ip_addr_cpy[20]; -// char ip[5]; - -// tstrncpy(ip_addr_cpy, ip_addr, sizeof(ip_addr_cpy)); - -// char *s_start, *s_end; -// s_start = ip_addr_cpy; -// s_end = ip_addr_cpy; - -// int32_t k = 0; - -// for (k = 0; *s_start != '\0'; s_start = s_end) { -// for (s_end = s_start; *s_end != '.' && *s_end != '\0'; s_end++) { -// } -// if (*s_end == '.') { -// *s_end = '\0'; -// s_end++; -// } -// dst[k++] = (char)atoi(s_start); -// } -// } - uint32_t subnetIpRang2Int(SIpV4Range* pRange) { uint32_t ip = pRange->ip; return ((ip & 0xFF) << 24) | ((ip & 0xFF00) << 8) | ((ip & 0xFF0000) >> 8) | ((ip >> 24) & 0xFF); @@ -778,7 +822,11 @@ int32_t transUtilSIpRangeToStr(SIpV4Range* pRange, char* buf) { struct in_addr addr; addr.s_addr = pRange->ip; - uv_inet_ntop(AF_INET, &addr, buf, 32); + int32_t err = uv_inet_ntop(AF_INET, &addr, buf, 32); + if (err != 0) { + tError("failed to convert ip to string, reason:%s", uv_strerror(err)); + return TSDB_CODE_THIRDPARTY_ERROR; + } len = strlen(buf); @@ -794,14 +842,23 @@ int32_t transUtilSWhiteListToStr(SIpWhiteList* pList, char** ppBuf) { *ppBuf = NULL; return 0; } + int32_t len = 0; char* pBuf = taosMemoryCalloc(1, pList->num * 36); + if (pBuf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } for (int i = 0; i < pList->num; i++) { SIpV4Range* pRange = &pList->pIpRange[i]; char tbuf[32] = {0}; int tlen = transUtilSIpRangeToStr(pRange, tbuf); + if (tlen < 0) { + taosMemoryFree(pBuf); + return tlen; + } + len += sprintf(pBuf + len, "%s,", tbuf); } if (len > 0) { diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index 674bb86fb5..2f6c687df2 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -122,7 +122,7 @@ typedef struct SServerObj { SIpWhiteListTab* uvWhiteListCreate(); void uvWhiteListDestroy(SIpWhiteListTab* pWhite); -void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver); +int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver); void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable); bool uvWhiteListCheckConn(SIpWhiteListTab* pWhite, SSvrConn* pConn); bool uvWhiteListFilte(SIpWhiteListTab* pWhite, char* user, uint32_t ip, int64_t ver); @@ -164,7 +164,7 @@ static FORCE_INLINE SSvrConn* createConn(void* hThrd); static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear /*clear handle or not*/); static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn); -static int reallocConnRef(SSvrConn* conn); +static int32_t reallocConnRef(SSvrConn* conn); static void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd); static void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd); @@ -181,8 +181,8 @@ static void* transWorkerThread(void* arg); static void* transAcceptThread(void* arg); // add handle loop -static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName); -static bool addHandleToAcceptloop(void* arg); +static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName); +static int32_t addHandleToAcceptloop(void* arg); #define SRV_RELEASE_UV(loop) \ do { \ @@ -202,7 +202,11 @@ static bool addHandleToAcceptloop(void* arg); void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SSvrConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; - transAllocBuffer(pBuf, buf); + int32_t code = transAllocBuffer(pBuf, buf); + if (code < 0) { + tError("conn %p failed to alloc buffer, since %s", conn, tstrerror(code)); + // destroyConn(conn, true); + } } // refers specifically to query or insert timeout @@ -221,8 +225,16 @@ static bool uvCheckIp(SIpV4Range* pRange, int32_t ip) { } SIpWhiteListTab* uvWhiteListCreate() { SIpWhiteListTab* pWhiteList = taosMemoryCalloc(1, sizeof(SIpWhiteListTab)); + if (pWhiteList == NULL) { + return NULL; + } pWhiteList->pList = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 0, HASH_NO_LOCK); + if (pWhiteList->pList == NULL) { + taosMemoryFree(pWhiteList); + return NULL; + } + pWhiteList->ver = -1; return pWhiteList; } @@ -240,17 +252,26 @@ void uvWhiteListDestroy(SIpWhiteListTab* pWhite) { taosMemoryFree(pWhite); } -void uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) { +int32_t uvWhiteListToStr(SWhiteUserList* plist, char* user, char** ppBuf) { char* tmp = NULL; int32_t tlen = transUtilSWhiteListToStr(plist->pList, &tmp); + if (tlen < 0) { + return tlen; + } + + char* pBuf = taosMemoryCalloc(1, tlen + 64); + if (pBuf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - char* pBuf = taosMemoryCalloc(1, tlen + 64); int32_t len = sprintf(pBuf, "user: %s, ver: %" PRId64 ", ip: {%s}", user, plist->ver, tmp); taosMemoryFree(tmp); *ppBuf = pBuf; + return len; } void uvWhiteListDebug(SIpWhiteListTab* pWrite) { + int32_t code = 0; SHashObj* pWhiteList = pWrite->pList; void* pIter = taosHashIterate(pWhiteList, NULL); while (pIter) { @@ -262,23 +283,35 @@ void uvWhiteListDebug(SIpWhiteListTab* pWrite) { SWhiteUserList* pUserList = *(SWhiteUserList**)pIter; char* buf = NULL; - uvWhiteListToStr(pUserList, user, &buf); - tDebug("ip-white-list %s", buf); + + code = uvWhiteListToStr(pUserList, user, &buf); + if (code != 0) { + tDebug("ip-white-list failed to debug to str since %s", buf); + } taosMemoryFree(buf); pIter = taosHashIterate(pWhiteList, pIter); } } -void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) { +int32_t uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, int64_t ver) { + int32_t code = 0; SHashObj* pWhiteList = pWhite->pList; SWhiteUserList** ppUserList = taosHashGet(pWhiteList, user, strlen(user)); if (ppUserList == NULL || *ppUserList == NULL) { SWhiteUserList* pUserList = taosMemoryCalloc(1, sizeof(SWhiteUserList)); + if (pUserList == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pUserList->ver = ver; pUserList->pList = plist; - taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*)); + code = taosHashPut(pWhiteList, user, strlen(user), &pUserList, sizeof(void*)); + if (code != 0) { + taosMemoryFree(pUserList); + return code; + } } else { SWhiteUserList* pUserList = *ppUserList; @@ -287,6 +320,7 @@ void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* plist, in pUserList->pList = plist; } uvWhiteListDebug(pWhite); + return 0; } void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable) { @@ -584,6 +618,10 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { STransMsg* pMsg = &smsg->msg; if (pMsg->pCont == 0) { pMsg->pCont = (void*)rpcMallocCont(0); + if (pMsg->pCont == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pMsg->contLen = 0; } STransMsgHead* pHead = transHeadFromCont(pMsg->pCont); @@ -598,7 +636,7 @@ static int uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { if (pConn->inType == TDMT_SCH_DROP_TASK && pMsg->code == TSDB_CODE_VND_INVALID_VGROUP_ID) { transQueuePop(&pConn->srvMsgs); destroySmsg(smsg); - return -1; + return TSDB_CODE_INVALID_MSG; } if (pConn->status == ConnNormal) { @@ -764,7 +802,11 @@ static void uvShutDownCb(uv_shutdown_t* req, int status) { } static bool uvRecvReleaseReq(SSvrConn* pConn, STransMsgHead* pHead) { if ((pHead)->release == 1 && (pHead->msgLen) == sizeof(*pHead)) { - reallocConnRef(pConn); + int32_t code = reallocConnRef(pConn); + if (code != 0) { + destroyConn(pConn, true); + return true; + } tTrace("conn %p received release request", pConn); STraceId traceId = pHead->traceId; @@ -935,23 +977,21 @@ void uvOnConnectionCb(uv_stream_t* q, ssize_t nread, const uv_buf_t* buf) { return; } - // uv_handle_type pending = uv_pipe_pending_type(pipe); - SSvrConn* pConn = createConn(pThrd); + if (pConn == NULL) { + uv_close((uv_handle_t*)q, NULL); + return; + } - pConn->pTransInst = pThrd->pTransInst; - /* init conn timer*/ - // uv_timer_init(pThrd->loop, &pConn->pTimer); - // pConn->pTimer.data = pConn; - - pConn->hostThrd = pThrd; - - // init client handle - pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); - uv_tcp_init(pThrd->loop, pConn->pTcp); - pConn->pTcp->data = pConn; - - // transSetConnOption((uv_tcp_t*)pConn->pTcp); + // pConn->pTransInst = pThrd->pTransInst; + // /* init conn timer*/ + // // uv_timer_init(pThrd->loop, &pConn->pTimer); + // // pConn->pTimer.data = pConn; + // pConn->hostThrd = pThrd; + // // init client handle + // pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); + // uv_tcp_init(pThrd->loop, pConn->pTcp); + // pConn->pTcp->data = pConn; if (uv_accept(q, (uv_stream_t*)(pConn->pTcp)) == 0) { uv_os_fd_t fd; @@ -1005,17 +1045,36 @@ void uvOnPipeConnectionCb(uv_connect_t* connect, int status) { SWorkThrd* pThrd = container_of(connect, SWorkThrd, connect_req); uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); } -static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { +static int32_t addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { + int32_t code = 0; pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); - if (0 != uv_loop_init(pThrd->loop)) { - return false; + if (pThrd->loop == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if ((code = uv_loop_init(pThrd->loop)) != 0) { + tError("failed to init loop since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } #if defined(WINDOWS) || defined(DARWIN) - uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + if (code != 0) { + tError("failed to init pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #else - uv_pipe_init(pThrd->loop, pThrd->pipe, 1); - uv_pipe_open(pThrd->pipe, pThrd->fd); + code = uv_pipe_init(pThrd->loop, pThrd->pipe, 1); + if (code != 0) { + tError("failed to init pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + + code = uv_pipe_open(pThrd->pipe, pThrd->fd); + if (code != 0) { + tError("failed to open pip since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #endif pThrd->pipe->data = pThrd; @@ -1023,50 +1082,86 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) { QUEUE_INIT(&pThrd->msg); pThrd->prepare = taosMemoryCalloc(1, sizeof(uv_prepare_t)); - uv_prepare_init(pThrd->loop, pThrd->prepare); - uv_prepare_start(pThrd->prepare, uvPrepareCb); + if (pThrd->prepare == NULL) { + tError("failed to init prepare"); + return TSDB_CODE_OUT_OF_MEMORY; + } + + code = uv_prepare_init(pThrd->loop, pThrd->prepare); + if (code != 0) { + tError("failed to init prepare since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } + + code = uv_prepare_start(pThrd->prepare, uvPrepareCb); + if (code != 0) { + tError("failed to start prepare since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } pThrd->prepare->data = pThrd; // conn set QUEUE_INIT(&pThrd->conn); - pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb); + code = transAsyncPoolCreate(pThrd->loop, 8, pThrd, uvWorkerAsyncCb, &pThrd->asyncPool); + if (code != 0) { + tError("failed to init async pool since:%s", tstrerror(code)); + return code; + } #if defined(WINDOWS) || defined(DARWIN) uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb); + #else - uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); + code = uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); + if (code != 0) { + tError("failed to start read pipe:%s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } #endif - return true; + return 0; } -static bool addHandleToAcceptloop(void* arg) { +static int32_t addHandleToAcceptloop(void* arg) { // impl later SServerObj* srv = arg; - int err = 0; - if ((err = uv_tcp_init(srv->loop, &srv->server)) != 0) { - tError("failed to init accept server:%s", uv_err_name(err)); - return false; + int code = 0; + if ((code = uv_tcp_init(srv->loop, &srv->server)) != 0) { + tError("failed to init accept server since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } // register an async here to quit server gracefully srv->pAcceptAsync = taosMemoryCalloc(1, sizeof(uv_async_t)); - uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb); + if (srv->pAcceptAsync == NULL) { + tError("failed to create async since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + return TSDB_CODE_OUT_OF_MEMORY; + } + + code = uv_async_init(srv->loop, srv->pAcceptAsync, uvAcceptAsyncCb); + if (code != 0) { + tError("failed to init async since:%s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; + } srv->pAcceptAsync->data = srv; struct sockaddr_in bind_addr; - uv_ip4_addr("0.0.0.0", srv->port, &bind_addr); - if ((err = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) { - tError("failed to bind:%s", uv_err_name(err)); - return false; + if ((code = uv_ip4_addr("0.0.0.0", srv->port, &bind_addr)) != 0) { + tError("failed to bind addr since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } - if ((err = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) { - tError("failed to listen:%s", uv_err_name(err)); - terrno = TSDB_CODE_RPC_PORT_EADDRINUSE; - return false; + + if ((code = uv_tcp_bind(&srv->server, (const struct sockaddr*)&bind_addr, 0)) != 0) { + tError("failed to bind since %s", uv_err_name(code)); + return TSDB_CODE_THIRDPARTY_ERROR; } - return true; + if ((code = uv_listen((uv_stream_t*)&srv->server, 4096 * 2, uvOnAcceptCb)) != 0) { + tError("failed to listen since %s", uv_err_name(code)); + return TSDB_CODE_RPC_PORT_EADDRINUSE; + } + return 0; } + void* transWorkerThread(void* arg) { setThreadName("trans-svr-work"); SWorkThrd* pThrd = (SWorkThrd*)arg; @@ -1076,35 +1171,84 @@ void* transWorkerThread(void* arg) { } static FORCE_INLINE SSvrConn* createConn(void* hThrd) { + int32_t code = 0; SWorkThrd* pThrd = hThrd; SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn)); + if (pConn == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } transReqQueueInit(&pConn->wreqQueue); QUEUE_INIT(&pConn->queue); - QUEUE_PUSH(&pThrd->conn, &pConn->queue); - transQueueInit(&pConn->srvMsgs, NULL); + if ((code = transQueueInit(&pConn->srvMsgs, NULL)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } + + if ((code = transInitBuffer(&pConn->readBuf)) != 0) { + TAOS_CHECK_GOTO(code, NULL, _end); + } memset(&pConn->regArg, 0, sizeof(pConn->regArg)); pConn->broken = false; pConn->status = ConnNormal; - transInitBuffer(&pConn->readBuf); SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); + if (exh == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + exh->handle = pConn; exh->pThrd = pThrd; exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); + } + QUEUE_INIT(&exh->q); - transAcquireExHandle(transGetRefMgt(), exh->refId); + + SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (pSelf != exh) { + TAOS_CHECK_GOTO(TSDB_CODE_REF_INVALID_ID, NULL, _end); + } STrans* pTransInst = pThrd->pTransInst; pConn->refId = exh->refId; QUEUE_INIT(&exh->q); transRefSrvHandle(pConn); tTrace("%s handle %p, conn %p created, refId:%" PRId64, transLabel(pTransInst), exh, pConn, pConn->refId); + + pConn->pTransInst = pThrd->pTransInst; + /* init conn timer*/ + // uv_timer_init(pThrd->loop, &pConn->pTimer); + // pConn->pTimer.data = pConn; + pConn->hostThrd = pThrd; + // init client handle + pConn->pTcp = (uv_tcp_t*)taosMemoryMalloc(sizeof(uv_tcp_t)); + if (pConn->pTcp == NULL) { + TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _end); + } + + code = uv_tcp_init(pThrd->loop, pConn->pTcp); + if (code != 0) { + tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), uv_strerror(code)); + TAOS_CHECK_GOTO(TSDB_CODE_THIRDPARTY_ERROR, NULL, _end); + } + pConn->pTcp->data = pConn; + return pConn; +_end: + if (pConn) { + transQueueDestroy(&pConn->srvMsgs); + transDestroyBuffer(&pConn->readBuf); + taosMemoryFree(pConn->pTcp); + taosMemoryFree(pConn); + pConn = NULL; + } + tError("%s failed to create conn since %s" PRId64, transLabel(pTransInst), tstrerror(code)); + return NULL; } static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear) { @@ -1125,16 +1269,33 @@ static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) { conn->regArg.init = 0; } } -static int reallocConnRef(SSvrConn* conn) { - transReleaseExHandle(transGetRefMgt(), conn->refId); - transRemoveExHandle(transGetRefMgt(), conn->refId); +static int32_t reallocConnRef(SSvrConn* conn) { + if (conn->refId > 0) { + transReleaseExHandle(transGetRefMgt(), conn->refId); + transRemoveExHandle(transGetRefMgt(), conn->refId); + } // avoid app continue to send msg on invalid handle SExHandle* exh = taosMemoryMalloc(sizeof(SExHandle)); + if (exh == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + exh->handle = conn; exh->pThrd = conn->hostThrd; exh->refId = transAddExHandle(transGetRefMgt(), exh); + if (exh->refId < 0) { + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + QUEUE_INIT(&exh->q); - transAcquireExHandle(transGetRefMgt(), exh->refId); + SExHandle* pSelf = transAcquireExHandle(transGetRefMgt(), exh->refId); + if (pSelf != exh) { + tError("conn %p failed to acquire handle", conn); + taosMemoryFree(exh); + return TSDB_CODE_REF_INVALID_ID; + } + conn->refId = exh->refId; return 0; @@ -1204,24 +1365,41 @@ static void uvPipeListenCb(uv_stream_t* handle, int status) { } void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { + int32_t code = 0; + SServerObj* srv = taosMemoryCalloc(1, sizeof(SServerObj)); - srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); + if (srv == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + tError("failed to init server since: %s", tstrerror(code)); + return NULL; + } + + srv->ip = ip; + srv->port = port; srv->numOfThreads = numOfThreads; srv->workerIdx = 0; srv->numOfWorkerReady = 0; + srv->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); srv->pThreadObj = (SWorkThrd**)taosMemoryCalloc(srv->numOfThreads, sizeof(SWorkThrd*)); srv->pipe = (uv_pipe_t**)taosMemoryCalloc(srv->numOfThreads, sizeof(uv_pipe_t*)); - srv->ip = ip; - srv->port = port; - uv_loop_init(srv->loop); + if (srv->loop == NULL || srv->pThreadObj == NULL || srv->pipe == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } - char pipeName[PATH_MAX]; + code = uv_loop_init(srv->loop); + if (code != 0) { + tError("failed to init server since: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } if (false == taosValidIpAndPort(srv->ip, srv->port)) { - terrno = TAOS_SYSTEM_ERROR(errno); + code = TAOS_SYSTEM_ERROR(errno); tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr()); goto End; } + char pipeName[PATH_MAX]; #if defined(WINDOWS) || defined(DARWIN) int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0); @@ -1259,7 +1437,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); thrd->pipe = &(srv->pipe[i][1]); // init read - if (false == addHandleToWorkloop(thrd, pipeName)) { + if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) { goto End; } @@ -1276,27 +1454,53 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, for (int i = 0; i < srv->numOfThreads; i++) { SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd)); + if (thrd == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } thrd->pTransInst = shandle; thrd->quit = false; thrd->pTransInst = shandle; thrd->pWhiteList = uvWhiteListCreate(); - - srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); - srv->pThreadObj[i] = thrd; - - uv_os_sock_t fds[2]; - if (uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE) != 0) { + if (thrd->pWhiteList == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; goto End; } - uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1); - uv_pipe_open(&(srv->pipe[i][0]), fds[1]); + srv->pipe[i] = (uv_pipe_t*)taosMemoryCalloc(2, sizeof(uv_pipe_t)); + if (srv->pipe[i] == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto End; + } + + srv->pThreadObj[i] = thrd; + + uv_os_sock_t fds[2]; + if ((code = uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE)) != 0) { + tError("failed to create pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } + + code = uv_pipe_init(srv->loop, &(srv->pipe[i][0]), 1); + if (code != 0) { + tError("failed to init pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } + + code = uv_pipe_open(&(srv->pipe[i][0]), fds[1]); + if (code != 0) { + tError("failed to init pipe, errmsg: %s", uv_err_name(code)); + code = TSDB_CODE_THIRDPARTY_ERROR; + goto End; + } thrd->pipe = &(srv->pipe[i][1]); // init read thrd->fd = fds[0]; - if (false == addHandleToWorkloop(thrd, pipeName)) { + if ((code = addHandleToWorkloop(thrd, pipeName)) != 0) { goto End; } @@ -1311,15 +1515,17 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, } #endif - if (false == addHandleToAcceptloop(srv)) { + if ((code = addHandleToAcceptloop(srv)) != 0) { goto End; } - int err = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv); - if (err == 0) { + code = taosThreadCreate(&srv->thread, NULL, transAcceptThread, (void*)srv); + if (code == 0) { tDebug("success to create accept-thread"); } else { - tError("failed to create accept-thread"); + code = TAOS_SYSTEM_ERROR(errno); + tError("failed to create accept-thread since %s", tstrerror(code)); + goto End; // clear all resource later } @@ -1328,6 +1534,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, return srv; End: transCloseServer(srv); + terrno = code; return NULL; } @@ -1341,9 +1548,14 @@ void uvHandleQuit(SSvrMsg* msg, SWorkThrd* thrd) { taosMemoryFree(msg); } void uvHandleRelease(SSvrMsg* msg, SWorkThrd* thrd) { + int32_t code = 0; SSvrConn* conn = msg->pConn; if (conn->status == ConnAcquire) { - reallocConnRef(conn); + code = reallocConnRef(conn); + if (code != 0) { + destroyConn(conn, true); + return; + } if (!transQueuePush(&conn->srvMsgs, msg)) { return; } @@ -1387,30 +1599,43 @@ void uvHandleRegister(SSvrMsg* msg, SWorkThrd* thrd) { } void uvHandleUpdate(SSvrMsg* msg, SWorkThrd* thrd) { SUpdateIpWhite* req = msg->arg; - if (req != NULL) { - for (int i = 0; i < req->numOfUser; i++) { - SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i]; - - int32_t sz = pUser->numOfRange * sizeof(SIpV4Range); - SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList)); - pList->num = pUser->numOfRange; - - memcpy(pList->pIpRange, pUser->pIpRanges, sz); - uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver); - } - - thrd->pWhiteList->ver = req->ver; - thrd->enableIpWhiteList = 1; - - tFreeSUpdateIpWhiteReq(req); - taosMemoryFree(req); - } else { + if (req == NULL) { tDebug("ip-white-list disable on trans"); thrd->enableIpWhiteList = 0; + taosMemoryFree(msg); + return; } + int32_t code = 0; + for (int i = 0; i < req->numOfUser; i++) { + SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i]; + + int32_t sz = pUser->numOfRange * sizeof(SIpV4Range); + + SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList)); + if (pList == NULL) { + tError("failed to create ip-white-list since %s", tstrerror(code)); + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pList->num = pUser->numOfRange; + memcpy(pList->pIpRange, pUser->pIpRanges, sz); + code = uvWhiteListAdd(thrd->pWhiteList, pUser->user, pList, pUser->ver); + if (code != 0) { + break; + } + } + + if (code == 0) { + thrd->pWhiteList->ver = req->ver; + thrd->enableIpWhiteList = 1; + } else { + tError("failed to update ip-white-list since %s", tstrerror(code)); + } + tFreeSUpdateIpWhiteReq(req); + taosMemoryFree(req); taosMemoryFree(msg); - return; } + void destroyWorkThrd(SWorkThrd* pThrd) { if (pThrd == NULL) { return; @@ -1483,6 +1708,7 @@ void transUnrefSrvHandle(void* handle) { } int transReleaseSrvHandle(void* handle) { + int32_t code = 0; SRpcHandleInfo* info = handle; SExHandle* exh = info->handle; int64_t refId = info->refId; @@ -1495,12 +1721,19 @@ int transReleaseSrvHandle(void* handle) { STransMsg tmsg = {.code = 0, .info.handle = exh, .info.ahandle = NULL, .info.refId = refId}; SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Release; tDebug("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + transReleaseExHandle(transGetRefMgt(), refId); + return code; } transReleaseExHandle(transGetRefMgt(), refId); @@ -1508,13 +1741,15 @@ int transReleaseSrvHandle(void* handle) { _return1: tDebug("handle %p failed to send to release handle", exh); transReleaseExHandle(transGetRefMgt(), refId); - return -1; + return code; _return2: tDebug("handle %p failed to send to release handle", exh); - return -1; + return code; } int transSendResponse(const STransMsg* msg) { + int32_t code = 0; + if (msg->info.noResp) { rpcFreeCont(msg->pCont); tTrace("no need send resp"); @@ -1536,13 +1771,20 @@ int transSendResponse(const STransMsg* msg) { ASYNC_ERR_JRET(pThrd); SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Normal; STraceId* trace = (STraceId*)&msg->info.traceId; tGDebug("conn %p start to send resp (1/2)", exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + transReleaseExHandle(transGetRefMgt(), refId); + return code; } transReleaseExHandle(transGetRefMgt(), refId); @@ -1552,13 +1794,15 @@ _return1: tDebug("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); transReleaseExHandle(transGetRefMgt(), refId); - return -1; + return code; _return2: tDebug("handle %p failed to send resp", exh); rpcFreeCont(msg->pCont); - return -1; + return code; } int transRegisterMsg(const STransMsg* msg) { + int32_t code = 0; + SExHandle* exh = msg->info.handle; int64_t refId = msg->info.refId; ASYNC_CHECK_HANDLE(exh, refId); @@ -1572,13 +1816,20 @@ int transRegisterMsg(const STransMsg* msg) { ASYNC_ERR_JRET(pThrd); SSvrMsg* m = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (m == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _return1; + } + m->msg = tmsg; m->type = Register; STrans* pTransInst = pThrd->pTransInst; tDebug("%s conn %p start to register brokenlink callback", transLabel(pTransInst), exh->handle); - if (0 != transAsyncSend(pThrd->asyncPool, &m->q)) { + if ((code = transAsyncSend(pThrd->asyncPool, &m->q)) != 0) { destroySmsg(m); + transReleaseExHandle(transGetRefMgt(), refId); + return code; } transReleaseExHandle(transGetRefMgt(), refId); @@ -1588,29 +1839,56 @@ _return1: tDebug("handle %p failed to register brokenlink", exh); rpcFreeCont(msg->pCont); transReleaseExHandle(transGetRefMgt(), refId); - return -1; + return code; _return2: tDebug("handle %p failed to register brokenlink", exh); rpcFreeCont(msg->pCont); - return -1; + return code; } -void transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) { + +int32_t transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) { STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)thandle); + if (pTransInst == NULL) { + return TSDB_CODE_RPC_MODULE_QUIT; + } + + int32_t code = 0; tDebug("ip-white-list update on rpc"); SServerObj* svrObj = pTransInst->tcphandle; for (int i = 0; i < svrObj->numOfThreads; i++) { SWorkThrd* pThrd = svrObj->pThreadObj[i]; - SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); - SUpdateIpWhite* pReq = (arg != NULL ? cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg) : NULL); + SSvrMsg* msg = taosMemoryCalloc(1, sizeof(SSvrMsg)); + if (msg == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + + SUpdateIpWhite* pReq = NULL; + code = cloneSUpdateIpWhiteReq((SUpdateIpWhite*)arg, &pReq); + if (code != 0) { + taosMemoryFree(msg); + break; + } msg->type = Update; msg->arg = pReq; - transAsyncSend(pThrd->asyncPool, &msg->q); + if ((code = transAsyncSend(pThrd->asyncPool, &msg->q)) != 0) { + code = (code == TSDB_CODE_RPC_ASYNC_MODULE_QUIT ? TSDB_CODE_RPC_MODULE_QUIT : code); + tFreeSUpdateIpWhiteReq(pReq); + taosMemoryFree(pReq); + taosMemoryFree(msg); + break; + } } transReleaseExHandle(transGetInstMgt(), (int64_t)thandle); + + if (code != 0) { + tError("ip-white-list update failed since %s", tstrerror(code)); + } + return code; } int transGetConnInfo(void* thandle, STransHandleInfo* pConnInfo) { return -1; } diff --git a/source/os/test/osSemaphoreTests.cpp b/source/os/test/osSemaphoreTests.cpp index 09fbe27f55..9347254b10 100644 --- a/source/os/test/osSemaphoreTests.cpp +++ b/source/os/test/osSemaphoreTests.cpp @@ -58,17 +58,17 @@ TEST(osSemaphoreTests, Destroy) { TEST(osSemaphoreTests, WaitTime0) { tsem_t sem; - tsem_init(&sem, 0, 0); + (void)tsem_init(&sem, 0, 0); EXPECT_NE(tsem_timewait(&sem, 1000), 0); - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } TEST(osSemaphoreTests, WaitTime1) { tsem_t sem; - tsem_init(&sem, 0, 1); + (void)tsem_init(&sem, 0, 1); EXPECT_EQ(tsem_timewait(&sem, 1000), 0); EXPECT_NE(tsem_timewait(&sem, 1000), 0); - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } TEST(osSemaphoreTests, WaitAndPost) { @@ -78,7 +78,7 @@ TEST(osSemaphoreTests, WaitAndPost) { std::thread([&sem]() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - tsem_post(&sem); + (void)tsem_post(&sem); }).detach(); result = tsem_wait(&sem); @@ -96,7 +96,7 @@ TEST(osSemaphoreTests, TimedWait) { std::thread([&sem]() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); - tsem_post(&sem); + (void)tsem_post(&sem); }).detach(); result = tsem_timewait(&sem, 1000); @@ -110,80 +110,80 @@ TEST(osSemaphoreTests, Performance1_1) { tsem_t sem; const int count = 100000; - tsem_init(&sem, 0, 0); + (void)tsem_init(&sem, 0, 0); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem_post(&sem); + (void)tsem_post(&sem); } }).detach(); for (int i = 0; i < count; ++i) { - tsem_wait(&sem); + (void)tsem_wait(&sem); } - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } TEST(osSemaphoreTests, Performance1_2) { tsem2_t sem; const int count = 100000; - tsem2_init(&sem, 0, 0); + (void)tsem2_init(&sem, 0, 0); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem2_post(&sem); + (void)tsem2_post(&sem); } }).detach(); for (int i = 0; i < count; ++i) { - tsem2_wait(&sem); + (void)tsem2_wait(&sem); } - tsem2_destroy(&sem); + (void)tsem2_destroy(&sem); } TEST(osSemaphoreTests, Performance2_1) { tsem_t sem; const int count = 50000; - tsem_init(&sem, 0, 0); + (void)tsem_init(&sem, 0, 0); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem_post(&sem); + (void)tsem_post(&sem); } }).detach(); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem_post(&sem); + (void)tsem_post(&sem); } }).detach(); for (int i = 0; i < count * 2; ++i) { - tsem_wait(&sem); + (void)tsem_wait(&sem); } - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } TEST(osSemaphoreTests, Performance2_2) { tsem2_t sem; const int count = 50000; - tsem2_init(&sem, 0, 0); + (void)tsem2_init(&sem, 0, 0); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem2_post(&sem); + (void)tsem2_post(&sem); } }).detach(); std::thread([&sem, count]() { for (int i = 0; i < count; ++i) { - tsem2_post(&sem); + (void)tsem2_post(&sem); } }).detach(); for (int i = 0; i < count * 2; ++i) { - tsem2_wait(&sem); + (void)tsem2_wait(&sem); } - tsem2_destroy(&sem); + (void)tsem2_destroy(&sem); } TEST(osSemaphoreTests, Performance3_1) { @@ -191,9 +191,9 @@ TEST(osSemaphoreTests, Performance3_1) { for (int i = 0; i < count; ++i) { tsem_t sem; - tsem_init(&sem, 0, 1); + (void)tsem_init(&sem, 0, 1); EXPECT_EQ(tsem_timewait(&sem, 1000), 0); - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } } @@ -202,9 +202,9 @@ TEST(osSemaphoreTests, Performance3_2) { for (int i = 0; i < count; ++i) { tsem2_t sem; - tsem2_init(&sem, 0, 1); + (void)tsem2_init(&sem, 0, 1); EXPECT_EQ(tsem2_timewait(&sem, 1000), 0); - tsem2_destroy(&sem); + (void)tsem2_destroy(&sem); } } @@ -212,14 +212,14 @@ TEST(osSemaphoreTests, Performance4_1) { const int count = 1000; for (int i = 0; i < count; ++i) { tsem_t sem; - tsem_init(&sem, 0, 0); + (void)tsem_init(&sem, 0, 0); std::thread([&sem, count]() { - tsem_post(&sem); + (void)tsem_post(&sem); }).detach(); - tsem_timewait(&sem, 1000); + (void)tsem_timewait(&sem, 1000); - tsem_destroy(&sem); + (void)tsem_destroy(&sem); } } @@ -227,13 +227,13 @@ TEST(osSemaphoreTests, Performance4_2) { const int count = 1000; for (int i = 0; i < count; ++i) { tsem2_t sem; - tsem2_init(&sem, 0, 0); + (void)tsem2_init(&sem, 0, 0); std::thread([&sem, count]() { - tsem2_post(&sem); + (void)tsem2_post(&sem); }).detach(); - tsem2_timewait(&sem, 1000); + (void)tsem2_timewait(&sem, 1000); - tsem2_destroy(&sem); + (void)tsem2_destroy(&sem); } } diff --git a/source/os/test/osSystemTests.cpp b/source/os/test/osSystemTests.cpp index 86c600f135..3712e45451 100644 --- a/source/os/test/osSystemTests.cpp +++ b/source/os/test/osSystemTests.cpp @@ -45,18 +45,18 @@ TEST(osSystemTest, osSystem1) { int64_t mem_system; // KB taosGetCpuUsage(&cpu_system, &cpu_engine); - taosGetCpuCores(&cpu_cores, false); + (void)taosGetCpuCores(&cpu_cores, false); - taosGetProcMemory(&mem_engine); - taosGetSysMemory(&mem_system); - printf("cpu_engine: %f cpu_system: %f\n", cpu_engine, cpu_system); - printf("cpu_cores: %f\n", cpu_cores); + (void)taosGetProcMemory(&mem_engine); + (void)taosGetSysMemory(&mem_system); + (void)printf("cpu_engine: %f cpu_system: %f\n", cpu_engine, cpu_system); + (void)printf("cpu_cores: %f\n", cpu_cores); ASSERT_GT(cpu_cores, 0); ASSERT_GE(mem_engine, 0); ASSERT_GE(mem_system, 0); float numOfCores = 0; int32_t res = taosGetCpuInfo(tmp, 4096, &numOfCores); - printf("cpu info: %s\n", tmp); + (void)printf("cpu info: %s\n", tmp); ASSERT_EQ(res, 0); } diff --git a/source/os/test/osTests.cpp b/source/os/test/osTests.cpp index f5a2394bbd..9786886c56 100644 --- a/source/os/test/osTests.cpp +++ b/source/os/test/osTests.cpp @@ -46,10 +46,10 @@ TEST(osTest, osFQDNSuccess) { struct in_addr addr; addr.s_addr = htonl(ipv4); - snprintf(ipString, INET_ADDRSTRLEN, "%u.%u.%u.%u", (unsigned int)(addr.s_addr >> 24) & 0xFF, + (void)snprintf(ipString, INET_ADDRSTRLEN, "%u.%u.%u.%u", (unsigned int)(addr.s_addr >> 24) & 0xFF, (unsigned int)(addr.s_addr >> 16) & 0xFF, (unsigned int)(addr.s_addr >> 8) & 0xFF, (unsigned int)(addr.s_addr) & 0xFF); - printf("fqdn:%s ip:%s\n", fqdn, ipString); + (void)printf("fqdn:%s ip:%s\n", fqdn, ipString); } TEST(osTest, osFQDNFailed) { @@ -60,7 +60,7 @@ TEST(osTest, osFQDNFailed) { ASSERT_NE(code, 0); terrno = TSDB_CODE_RPC_FQDN_ERROR; - printf("fqdn:%s transfer to ip failed!\n", fqdn); + (void)printf("fqdn:%s transfer to ip failed!\n", fqdn); } #endif // WINDOWS @@ -74,27 +74,27 @@ TEST(osTest, osSystem) { const int sysLen = 64; char osSysName[sysLen]; int ret = taosGetOsReleaseName(osSysName, NULL, NULL, sysLen); - printf("os system name:%s\n", osSysName); + (void)printf("os system name:%s\n", osSysName); ASSERT_EQ(ret, 0); } void fileOperateOnFree(void *param) { char * fname = (char *)param; TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); - printf("On free thread open file\n"); + (void)printf("On free thread open file\n"); ASSERT_NE(pFile, nullptr); int ret = taosLockFile(pFile); - printf("On free thread lock file ret:%d\n", ret); + (void)printf("On free thread lock file ret:%d\n", ret); ASSERT_EQ(ret, 0); ret = taosUnLockFile(pFile); - printf("On free thread unlock file ret:%d\n", ret); + (void)printf("On free thread unlock file ret:%d\n", ret); ASSERT_EQ(ret, 0); ret = taosCloseFile(&pFile); ASSERT_EQ(ret, 0); - printf("On free thread close file ret:%d\n", ret); + (void)printf("On free thread close file ret:%d\n", ret); } void *fileOperateOnFreeThread(void *param) { fileOperateOnFree(param); @@ -103,19 +103,19 @@ void *fileOperateOnFreeThread(void *param) { void fileOperateOnBusy(void *param) { char * fname = (char *)param; TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); - printf("On busy thread open file\n"); + (void)printf("On busy thread open file\n"); if (pFile == NULL) return; // ASSERT_NE(pFile, nullptr); int ret = taosLockFile(pFile); - printf("On busy thread lock file ret:%d\n", ret); + (void)printf("On busy thread lock file ret:%d\n", ret); ASSERT_NE(ret, 0); ret = taosUnLockFile(pFile); - printf("On busy thread unlock file ret:%d\n", ret); + (void)printf("On busy thread unlock file ret:%d\n", ret); ret = taosCloseFile(&pFile); - printf("On busy thread close file ret:%d\n", ret); + (void)printf("On busy thread close file ret:%d\n", ret); ASSERT_EQ(ret, 0); } void *fileOperateOnBusyThread(void *param) { @@ -128,41 +128,41 @@ TEST(osTest, osFile) { TdFilePtr pOutFD = taosCreateFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); ASSERT_NE(pOutFD, nullptr); - printf("create file success\n"); - taosCloseFile(&pOutFD); + (void)printf("create file success\n"); + (void)taosCloseFile(&pOutFD); - taosCloseFile(&pOutFD); + (void)taosCloseFile(&pOutFD); TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); - printf("open file\n"); + (void)printf("open file\n"); ASSERT_NE(pFile, nullptr); int ret = taosLockFile(pFile); - printf("lock file ret:%d\n", ret); + (void)printf("lock file ret:%d\n", ret); ASSERT_EQ(ret, 0); TdThreadAttr thattr; - taosThreadAttrInit(&thattr); + (void)taosThreadAttrInit(&thattr); TdThread thread1, thread2; - taosThreadCreate(&(thread1), &thattr, fileOperateOnBusyThread, (void *)fname); - taosThreadAttrDestroy(&thattr); + (void)taosThreadCreate(&(thread1), &thattr, fileOperateOnBusyThread, (void *)fname); + (void)taosThreadAttrDestroy(&thattr); - taosThreadJoin(thread1, NULL); + (void)taosThreadJoin(thread1, NULL); taosThreadClear(&thread1); ret = taosUnLockFile(pFile); - printf("unlock file ret:%d\n", ret); + (void)printf("unlock file ret:%d\n", ret); ASSERT_EQ(ret, 0); ret = taosCloseFile(&pFile); - printf("close file ret:%d\n", ret); + (void)printf("close file ret:%d\n", ret); ASSERT_EQ(ret, 0); - taosThreadCreate(&(thread2), &thattr, fileOperateOnFreeThread, (void *)fname); - taosThreadAttrDestroy(&thattr); + (void)taosThreadCreate(&(thread2), &thattr, fileOperateOnFreeThread, (void *)fname); + (void)taosThreadAttrDestroy(&thattr); - taosThreadJoin(thread2, NULL); + (void)taosThreadJoin(thread2, NULL); taosThreadClear(&thread2); //int ret = taosRemoveFile(fname); @@ -201,8 +201,8 @@ int64_t fillBufferWithRandomWords(char *buffer, int64_t maxBufferSize) { size_t wordLen = strlen(word); if (len + wordLen + 1 < maxBufferSize) { - strcat(buffer, word); - strcat(buffer, " "); + (void)strcat(buffer, word); + (void)strcat(buffer, " "); len += wordLen + 1; } else { break; @@ -240,7 +240,7 @@ int64_t calculateMin(int64_t arr[], int size) { } TEST(osTest, osFilePerformance) { - printf("os file performance testting...\n"); + (void)printf("os file performance testting...\n"); int64_t WriteFileCost; int64_t ReadFileCost; int64_t OpenForWriteCloseFileCost; @@ -254,47 +254,47 @@ TEST(osTest, osFilePerformance) { TdFilePtr pOutFD = taosCreateFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); ASSERT_NE(pOutFD, nullptr); - taosCloseFile(&pOutFD); + (void)taosCloseFile(&pOutFD); - printf("os file performance start write...\n"); + (void)printf("os file performance start write...\n"); int64_t t1 = taosGetTimestampUs(); for (int i = 0; i < TESTTIMES; ++i) { TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_WRITE_THROUGH); ASSERT_NE(pFile, nullptr); - taosWriteFile(pFile, writeBuffer, size); - taosFsyncFile(pFile); - taosCloseFile(&pFile); + (void)taosWriteFile(pFile, writeBuffer, size); + (void)taosFsyncFile(pFile); + (void)taosCloseFile(&pFile); } int64_t t2 = taosGetTimestampUs(); WriteFileCost = t2 - t1; - printf("os file performance start read...\n"); + (void)printf("os file performance start read...\n"); for (int i = 0; i < TESTTIMES; ++i) { TdFilePtr pFile = taosOpenFile(fname, TD_FILE_READ); ASSERT_NE(pFile, nullptr); - taosReadFile(pFile, readBuffer, size); - taosCloseFile(&pFile); + (void)taosReadFile(pFile, readBuffer, size); + (void)taosCloseFile(&pFile); int readLine = strlen(readBuffer); ASSERT_EQ(size, readLine); } int64_t t3 = taosGetTimestampUs(); ReadFileCost = t3 - t2; - printf("os file performance start open1...\n"); + (void)printf("os file performance start open1...\n"); for (int i = 0; i < TESTTIMES; ++i) { TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_WRITE); ASSERT_NE(pFile, nullptr); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); } int64_t t4 = taosGetTimestampUs(); OpenForWriteCloseFileCost = t4 - t3; - printf("os file performance start open2...\n"); + (void)printf("os file performance start open2...\n"); for (int i = 0; i < TESTTIMES; ++i) { TdFilePtr pFile = taosOpenFile(fname, TD_FILE_CREATE | TD_FILE_READ); ASSERT_NE(pFile, nullptr); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); } int64_t t5 = taosGetTimestampUs(); OpenForReadCloseFileCost = t5 - t4; @@ -336,10 +336,10 @@ TEST(osTest, osFilePerformance) { taosMemoryFree(writeBuffer); taosMemoryFree(readBuffer); - printf("Test Write file %d times, cost: %" PRId64 "us\n", TESTTIMES, WriteFileCost); - printf("Test Read file %d times, cost: %" PRId64 "us\n", TESTTIMES, ReadFileCost); - printf("Test OpenForWrite & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForWriteCloseFileCost); - printf("Test OpenForRead & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForReadCloseFileCost); + (void)printf("Test Write file %d times, cost: %" PRId64 "us\n", TESTTIMES, WriteFileCost); + (void)printf("Test Read file %d times, cost: %" PRId64 "us\n", TESTTIMES, ReadFileCost); + (void)printf("Test OpenForWrite & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForWriteCloseFileCost); + (void)printf("Test OpenForRead & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForReadCloseFileCost); } #endif // OSFILE_PERFORMANCE_TEST diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index 17b985b5e0..0d9352190b 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -112,7 +112,7 @@ static FORCE_INLINE void __trashcan_wr_lock(SCacheObj *pCacheObj) { #if defined(LINUX) taosThreadRwlockWrlock(&pCacheObj->lock); #else - taosThreadMutexLock(&pCacheObj->lock); + (void)taosThreadMutexLock(&pCacheObj->lock); #endif } @@ -120,7 +120,7 @@ static FORCE_INLINE void __trashcan_unlock(SCacheObj *pCacheObj) { #if defined(LINUX) taosThreadRwlockUnlock(&pCacheObj->lock); #else - taosThreadMutexUnlock(&pCacheObj->lock); + (void)taosThreadMutexUnlock(&pCacheObj->lock); #endif } @@ -168,9 +168,9 @@ static void doInitRefreshThread(void) { TdThread doRegisterCacheObj(SCacheObj *pCacheObj) { taosThreadOnce(&cacheThreadInit, doInitRefreshThread); - taosThreadMutexLock(&guard); + (void)taosThreadMutexLock(&guard); (void)taosArrayPush(pCacheArrayList, &pCacheObj); - taosThreadMutexUnlock(&guard); + (void)taosThreadMutexUnlock(&guard); return cacheRefreshWorker; } @@ -840,19 +840,19 @@ void *taosCacheTimedRefresh(void *handle) { goto _end; } - taosThreadMutexLock(&guard); + (void)taosThreadMutexLock(&guard); size_t size = taosArrayGetSize(pCacheArrayList); - taosThreadMutexUnlock(&guard); + (void)taosThreadMutexUnlock(&guard); count += 1; for (int32_t i = 0; i < size; ++i) { - taosThreadMutexLock(&guard); + (void)taosThreadMutexLock(&guard); SCacheObj *pCacheObj = taosArrayGetP(pCacheArrayList, i); if (pCacheObj == NULL) { uError("object is destroyed. ignore and try next"); - taosThreadMutexUnlock(&guard); + (void)taosThreadMutexUnlock(&guard); continue; } @@ -864,11 +864,11 @@ void *taosCacheTimedRefresh(void *handle) { uDebug("%s is destroying, remove it from refresh list, remain cache obj:%" PRIzu, pCacheObj->name, size); pCacheObj->deleting = 0; // reset the deleting flag to enable pCacheObj to continue releasing resources. - taosThreadMutexUnlock(&guard); + (void)taosThreadMutexUnlock(&guard); continue; } - taosThreadMutexUnlock(&guard); + (void)taosThreadMutexUnlock(&guard); if ((count % pCacheObj->checkTick) != 0) { continue; diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 42bedf01b7..4cb48bffe5 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -1282,7 +1282,7 @@ int32_t checkRegexPattern(const char *pPattern) { int32_t ret = regcomp(®ex, pPattern, cflags); if (ret != 0) { char msgbuf[256] = {0}; - regerror(ret, ®ex, msgbuf, tListLen(msgbuf)); + (void)regerror(ret, ®ex, msgbuf, tListLen(msgbuf)); uError("Failed to compile regex pattern %s. reason %s", pPattern, msgbuf); return TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR; } @@ -1307,7 +1307,7 @@ static UsingRegex **getRegComp(const char *pPattern) { int32_t ret = regcomp(&pUsingRegex->pRegex, pPattern, cflags); if (ret != 0) { char msgbuf[256] = {0}; - regerror(ret, &pUsingRegex->pRegex, msgbuf, tListLen(msgbuf)); + (void)regerror(ret, &pUsingRegex->pRegex, msgbuf, tListLen(msgbuf)); uError("Failed to compile regex pattern %s. reason %s", pPattern, msgbuf); taosMemoryFree(pUsingRegex); terrno = TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR; @@ -1354,7 +1354,7 @@ static int32_t doExecRegexMatch(const char *pString, const char *pPattern) { releaseRegComp(pUsingRegex); if (ret != 0 && ret != REG_NOMATCH) { terrno = TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR; - regerror(ret, &(*pUsingRegex)->pRegex, msgbuf, sizeof(msgbuf)); + (void)regerror(ret, &(*pUsingRegex)->pRegex, msgbuf, sizeof(msgbuf)); uDebug("Failed to match %s with pattern %s, reason %s", pString, pPattern, msgbuf) } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 1200cbfb5a..565a27f86a 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -55,8 +55,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TIMEOUT, "Conn read timeout") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED, "some vnode/qnode/mnode(s) out of service") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MAX_SESSIONS, "rpc open too many session") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_ERROR, "rpc network error") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy") -TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_BUSY, "rpc network busy") +TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_MODULE_QUIT, "http-report already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_MODULE_QUIT, "rpc module already quit") +TAOS_DEFINE_ERROR(TSDB_CODE_RPC_ASYNC_MODULE_QUIT, "rpc async module already quit") //common & util TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized") diff --git a/source/util/src/tidpool.c b/source/util/src/tidpool.c index cfb2be5f02..46e68c0818 100644 --- a/source/util/src/tidpool.c +++ b/source/util/src/tidpool.c @@ -44,7 +44,7 @@ int32_t taosAllocateId(id_pool_t *pIdPool) { if (pIdPool == NULL) return -1; int32_t slot = -1; - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); if (pIdPool->numOfFree > 0) { for (int32_t i = 0; i < pIdPool->maxId; ++i) { @@ -58,14 +58,14 @@ int32_t taosAllocateId(id_pool_t *pIdPool) { } } - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); return slot + 1; } void taosFreeId(id_pool_t *pIdPool, int32_t id) { if (pIdPool == NULL) return; - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); int32_t slot = (id - 1) % pIdPool->maxId; if (pIdPool->freeList[slot]) { @@ -73,7 +73,7 @@ void taosFreeId(id_pool_t *pIdPool, int32_t id) { pIdPool->numOfFree++; } - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); } void taosIdPoolCleanUp(id_pool_t *pIdPool) { @@ -91,16 +91,16 @@ void taosIdPoolCleanUp(id_pool_t *pIdPool) { } int32_t taosIdPoolNumOfUsed(id_pool_t *pIdPool) { - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); int32_t ret = pIdPool->maxId - pIdPool->numOfFree; - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); return ret; } bool taosIdPoolMarkStatus(id_pool_t *pIdPool, int32_t id) { bool ret = false; - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); int32_t slot = (id - 1) % pIdPool->maxId; if (!pIdPool->freeList[slot]) { @@ -111,7 +111,7 @@ bool taosIdPoolMarkStatus(id_pool_t *pIdPool, int32_t id) { ret = false; } - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); return ret; } @@ -125,7 +125,7 @@ int32_t taosUpdateIdPool(id_pool_t *pIdPool, int32_t maxId) { return terrno; } - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); memcpy(idList, pIdPool->freeList, sizeof(bool) * pIdPool->maxId); pIdPool->numOfFree += (maxId - pIdPool->maxId); @@ -135,15 +135,15 @@ int32_t taosUpdateIdPool(id_pool_t *pIdPool, int32_t maxId) { pIdPool->freeList = idList; taosMemoryFree(oldIdList); - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); return 0; } int32_t taosIdPoolMaxSize(id_pool_t *pIdPool) { - taosThreadMutexLock(&pIdPool->mutex); + (void)taosThreadMutexLock(&pIdPool->mutex); int32_t ret = pIdPool->maxId; - taosThreadMutexUnlock(&pIdPool->mutex); + (void)taosThreadMutexUnlock(&pIdPool->mutex); return ret; } \ No newline at end of file diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 6d4bf89c0a..fa2c2cc3ed 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -362,7 +362,7 @@ static void *taosThreadToCloseOldFile(void *param) { } static int32_t taosOpenNewLogFile() { - taosThreadMutexLock(&tsLogObj.logMutex); + (void)taosThreadMutexLock(&tsLogObj.logMutex); if (tsLogObj.lines > tsNumOfLogLines && tsLogObj.openInProgress == 0) { tsLogObj.openInProgress = 1; @@ -378,7 +378,7 @@ static int32_t taosOpenNewLogFile() { taosThreadAttrDestroy(&attr); } - taosThreadMutexUnlock(&tsLogObj.logMutex); + (void)taosThreadMutexUnlock(&tsLogObj.logMutex); return 0; } @@ -719,7 +719,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg if (pLogBuf == NULL || pLogBuf->stop) return -1; - taosThreadMutexLock(&LOG_BUF_MUTEX(pLogBuf)); + (void)taosThreadMutexLock(&LOG_BUF_MUTEX(pLogBuf)); start = LOG_BUF_START(pLogBuf); end = LOG_BUF_END(pLogBuf); @@ -733,7 +733,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) { lostLine++; tsAsyncLogLostLines++; - taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); + (void)taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); return -1; } @@ -754,7 +754,7 @@ static int32_t taosPushLogBuffer(SLogBuff *pLogBuf, const char *msg, int32_t msg } */ - taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); + (void)taosThreadMutexUnlock(&LOG_BUF_MUTEX(pLogBuf)); return 0; } diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index e08dc009fc..5d28eeafb1 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -320,7 +320,7 @@ static void taosLRUCacheShardEvictLRU(SLRUCacheShard *shard, size_t charge, SArr ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); taosLRUCacheShardLRURemove(shard, old); - taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); ASSERT(shard->usage >= old->totalCharge); @@ -531,7 +531,7 @@ static void taosLRUCacheShardEraseUnrefEntries(SLRUCacheShard *shard) { SLRUEntry *old = shard->lru.next; ASSERT(TAOS_LRU_ENTRY_IN_CACHE(old) && !TAOS_LRU_ENTRY_HAS_REFS(old)); taosLRUCacheShardLRURemove(shard, old); - taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); + (void)taosLRUEntryTableRemove(&shard->table, old->keyData, old->keyLength, old->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(old, false); ASSERT(shard->usage >= old->totalCharge); shard->usage -= old->totalCharge; @@ -577,7 +577,7 @@ static bool taosLRUCacheShardRelease(SLRUCacheShard *shard, LRUHandle *handle, b if (shard->usage > shard->capacity || eraseIfLastRef) { ASSERT(shard->lru.next == &shard->lru || eraseIfLastRef); - taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); + (void)taosLRUEntryTableRemove(&shard->table, e->keyData, e->keyLength, e->hash); TAOS_LRU_ENTRY_SET_IN_CACHE(e, false); } else { taosLRUCacheShardLRUInsert(shard, e); diff --git a/source/util/src/tqueue.c b/source/util/src/tqueue.c index b2d2622407..c6b029ea01 100644 --- a/source/util/src/tqueue.c +++ b/source/util/src/tqueue.c @@ -86,11 +86,11 @@ void taosCloseQueue(STaosQueue *queue) { STaosQnode *pTemp; STaosQset *qset; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); STaosQnode *pNode = queue->head; queue->head = NULL; qset = queue->qset; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); if (queue->qset) { taosRemoveFromQset(qset, queue); @@ -112,11 +112,11 @@ bool taosQueueEmpty(STaosQueue *queue) { if (queue == NULL) return true; bool empty = false; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); if (queue->head == NULL && queue->tail == NULL && queue->numOfItems == 0 /*&& queue->memOfItems == 0*/) { empty = true; } - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); return empty; } @@ -124,26 +124,26 @@ bool taosQueueEmpty(STaosQueue *queue) { void taosUpdateItemSize(STaosQueue *queue, int32_t items) { if (queue == NULL) return; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); queue->numOfItems -= items; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); } int32_t taosQueueItemSize(STaosQueue *queue) { if (queue == NULL) return 0; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); int32_t numOfItems = queue->numOfItems; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); uTrace("queue:%p, numOfItems:%d memOfItems:%" PRId64, queue, queue->numOfItems, queue->memOfItems); return numOfItems; } int64_t taosQueueMemorySize(STaosQueue *queue) { - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); int64_t memOfItems = queue->memOfItems; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); return memOfItems; } @@ -198,19 +198,19 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { pNode->timestamp = taosGetTimestampUs(); pNode->next = NULL; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); if (queue->memLimit > 0 && (queue->memOfItems + pNode->size + pNode->dataSize) > queue->memLimit) { code = TSDB_CODE_UTIL_QUEUE_OUT_OF_MEMORY; uError("item:%p failed to put into queue:%p, queue mem limit: %" PRId64 ", reason: %s" PRId64, pItem, queue, queue->memLimit, tstrerror(code)); - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); return code; } else if (queue->itemLimit > 0 && queue->numOfItems + 1 > queue->itemLimit) { code = TSDB_CODE_UTIL_QUEUE_OUT_OF_MEMORY; uError("item:%p failed to put into queue:%p, queue size limit: %" PRId64 ", reason: %s" PRId64, pItem, queue, queue->itemLimit, tstrerror(code)); - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); return code; } @@ -229,7 +229,7 @@ int32_t taosWriteQitem(STaosQueue *queue, void *pItem) { uTrace("item:%p is put into queue:%p, items:%d mem:%" PRId64, pItem, queue, queue->numOfItems, queue->memOfItems); - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); if (queue->qset) { tsem_post(&queue->qset->sem); @@ -241,7 +241,7 @@ int32_t taosReadQitem(STaosQueue *queue, void **ppItem) { STaosQnode *pNode = NULL; int32_t code = 0; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); if (queue->head) { pNode = queue->head; @@ -260,7 +260,7 @@ int32_t taosReadQitem(STaosQueue *queue, void **ppItem) { queue->memOfItems); } - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); return code; } @@ -279,7 +279,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) { int32_t numOfItems = 0; bool empty; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); empty = queue->head == NULL; if (!empty) { @@ -305,7 +305,7 @@ int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall) { } } - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); // if source queue is empty, we set destination qall to empty too. if (empty) { @@ -355,7 +355,7 @@ void taosCloseQset(STaosQset *qset) { if (qset == NULL) return; // remove all the queues from qset - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); while (qset->head) { STaosQueue *queue = qset->head; qset->head = qset->head->next; @@ -363,7 +363,7 @@ void taosCloseQset(STaosQset *qset) { queue->qset = NULL; queue->next = NULL; } - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); taosThreadMutexDestroy(&qset->mutex); tsem_destroy(&qset->sem); @@ -382,19 +382,19 @@ void taosQsetThreadResume(STaosQset *qset) { int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) { if (queue->qset) return -1; - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); queue->next = qset->head; queue->ahandle = ahandle; qset->head = queue; qset->numOfQueues++; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); atomic_add_fetch_32(&qset->numOfItems, queue->numOfItems); queue->qset = qset; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); uTrace("queue:%p is added into qset:%p", queue, qset); return 0; @@ -403,7 +403,7 @@ int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle) { void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) { STaosQueue *tqueue = NULL; - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); if (qset->head) { if (qset->head == queue) { @@ -427,15 +427,15 @@ void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue) { if (qset->current == queue) qset->current = tqueue->next; qset->numOfQueues--; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); atomic_sub_fetch_32(&qset->numOfItems, queue->numOfItems); queue->qset = NULL; queue->next = NULL; - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); } } - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); uDebug("queue:%p is removed from qset:%p", queue, qset); } @@ -446,7 +446,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) tsem_wait(&qset->sem); - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); for (int32_t i = 0; i < qset->numOfQueues; ++i) { if (qset->current == NULL) qset->current = qset->head; @@ -455,7 +455,7 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) if (queue == NULL) break; if (queue->head == NULL) continue; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); if (queue->head) { pNode = queue->head; @@ -475,11 +475,11 @@ int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo) queue->memOfItems); } - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); if (pNode) break; } - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); return code; } @@ -489,7 +489,7 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * int32_t code = 0; tsem_wait(&qset->sem); - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); for (int32_t i = 0; i < qset->numOfQueues; ++i) { if (qset->current == NULL) qset->current = qset->head; @@ -498,7 +498,7 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * if (queue == NULL) break; if (queue->head == NULL) continue; - taosThreadMutexLock(&queue->mutex); + (void)taosThreadMutexLock(&queue->mutex); if (queue->head) { qall->current = queue->head; @@ -526,12 +526,12 @@ int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo * } } - taosThreadMutexUnlock(&queue->mutex); + (void)taosThreadMutexUnlock(&queue->mutex); if (code != 0) break; } - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); return code; } @@ -554,11 +554,11 @@ void taosResetQsetThread(STaosQset *qset, void *pItem) { if (pItem == NULL) return; STaosQnode *pNode = (STaosQnode *)((char *)pItem - sizeof(STaosQnode)); - taosThreadMutexLock(&qset->mutex); + (void)taosThreadMutexLock(&qset->mutex); for (int32_t i = 0; i < pNode->queue->numOfItems; ++i) { tsem_post(&qset->sem); } - taosThreadMutexUnlock(&qset->mutex); + (void)taosThreadMutexUnlock(&qset->mutex); } #endif diff --git a/source/util/src/tref.c b/source/util/src/tref.c index 5583286280..fe55335fce 100644 --- a/source/util/src/tref.c +++ b/source/util/src/tref.c @@ -76,7 +76,7 @@ int32_t taosOpenRef(int32_t max, RefFp fp) { return terrno = TSDB_CODE_OUT_OF_MEMORY; } - taosThreadMutexLock(&tsRefMutex); + (void)taosThreadMutexLock(&tsRefMutex); for (i = 0; i < TSDB_REF_OBJECTS; ++i) { tsNextId = (tsNextId + 1) % TSDB_REF_OBJECTS; @@ -105,7 +105,7 @@ int32_t taosOpenRef(int32_t max, RefFp fp) { uTrace("run out of Ref ID, maximum:%d refSetNum:%d", TSDB_REF_OBJECTS, tsRefSetNum); } - taosThreadMutexUnlock(&tsRefMutex); + (void)taosThreadMutexUnlock(&tsRefMutex); return rsetId; } @@ -121,7 +121,7 @@ int32_t taosCloseRef(int32_t rsetId) { pSet = tsRefSetList + rsetId; - taosThreadMutexLock(&tsRefMutex); + (void)taosThreadMutexLock(&tsRefMutex); if (pSet->state == TSDB_REF_STATE_ACTIVE) { pSet->state = TSDB_REF_STATE_DELETED; @@ -131,7 +131,7 @@ int32_t taosCloseRef(int32_t rsetId) { uTrace("rsetId:%d is already closed, count:%d", rsetId, pSet->count); } - taosThreadMutexUnlock(&tsRefMutex); + (void)taosThreadMutexUnlock(&tsRefMutex); if (deleted) taosDecRsetCount(pSet); @@ -349,7 +349,7 @@ int32_t taosListRef() { SRefNode *pNode; int32_t num = 0; - taosThreadMutexLock(&tsRefMutex); + (void)taosThreadMutexLock(&tsRefMutex); for (int32_t i = 0; i < TSDB_REF_OBJECTS; ++i) { pSet = tsRefSetList + i; @@ -369,7 +369,7 @@ int32_t taosListRef() { } } - taosThreadMutexUnlock(&tsRefMutex); + (void)taosThreadMutexUnlock(&tsRefMutex); return num; } @@ -475,7 +475,7 @@ static void taosDecRsetCount(SRefSet *pSet) { if (count > 0) return; - taosThreadMutexLock(&tsRefMutex); + (void)taosThreadMutexLock(&tsRefMutex); if (pSet->state != TSDB_REF_STATE_EMPTY) { pSet->state = TSDB_REF_STATE_EMPTY; @@ -489,5 +489,5 @@ static void taosDecRsetCount(SRefSet *pSet) { uTrace("rsetId:%d is cleaned, refSetNum:%d count:%d", pSet->rsetId, tsRefSetNum, pSet->count); } - taosThreadMutexUnlock(&tsRefMutex); + (void)taosThreadMutexUnlock(&tsRefMutex); } diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 5f6439d8f6..777eb23caa 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -230,7 +230,7 @@ static void addToWheel(tmr_obj_t* timer, uint32_t delay) { timer->prev = NULL; timer->expireAt = taosGetMonotonicMs() + delay; - taosThreadMutexLock(&wheel->mutex); + (void)taosThreadMutexLock(&wheel->mutex); uint32_t idx = 0; if (timer->expireAt > wheel->nextScanAt) { @@ -248,7 +248,7 @@ static void addToWheel(tmr_obj_t* timer, uint32_t delay) { p->prev = timer; } - taosThreadMutexUnlock(&wheel->mutex); + (void)taosThreadMutexUnlock(&wheel->mutex); } static bool removeFromWheel(tmr_obj_t* timer) { @@ -259,7 +259,7 @@ static bool removeFromWheel(tmr_obj_t* timer) { time_wheel_t* wheel = wheels + wheelIdx; bool removed = false; - taosThreadMutexLock(&wheel->mutex); + (void)taosThreadMutexLock(&wheel->mutex); // other thread may modify timer->wheel, check again. if (timer->wheel < tListLen(wheels)) { if (timer->prev != NULL) { @@ -277,7 +277,7 @@ static bool removeFromWheel(tmr_obj_t* timer) { timerDecRef(timer); removed = true; } - taosThreadMutexUnlock(&wheel->mutex); + (void)taosThreadMutexUnlock(&wheel->mutex); return removed; } @@ -372,7 +372,7 @@ static void taosTimerLoopFunc(int32_t signo) { time_wheel_t* wheel = wheels + i; while (now >= wheel->nextScanAt) { - taosThreadMutexLock(&wheel->mutex); + (void)taosThreadMutexLock(&wheel->mutex); wheel->index = (wheel->index + 1) % wheel->size; tmr_obj_t* timer = wheel->slots[wheel->index]; while (timer != NULL) { @@ -407,7 +407,7 @@ static void taosTimerLoopFunc(int32_t signo) { timer = next; } wheel->nextScanAt += wheel->resolution; - taosThreadMutexUnlock(&wheel->mutex); + (void)taosThreadMutexUnlock(&wheel->mutex); } addToExpired(expired); @@ -594,13 +594,13 @@ void* taosTmrInit(int32_t maxNumOfTmrs, int32_t resolution, int32_t longest, con return NULL; } - taosThreadMutexLock(&tmrCtrlMutex); + (void)taosThreadMutexLock(&tmrCtrlMutex); tmr_ctrl_t* ctrl = unusedTmrCtrl; if (ctrl != NULL) { unusedTmrCtrl = ctrl->next; numOfTmrCtrl++; } - taosThreadMutexUnlock(&tmrCtrlMutex); + (void)taosThreadMutexUnlock(&tmrCtrlMutex); if (ctrl == NULL) { tmrError("%s too many timer controllers, failed to create timer controller.", label); @@ -623,11 +623,11 @@ void taosTmrCleanUp(void* handle) { tmrDebug("%s timer controller is cleaned up.", ctrl->label); ctrl->label[0] = 0; - taosThreadMutexLock(&tmrCtrlMutex); + (void)taosThreadMutexLock(&tmrCtrlMutex); ctrl->next = unusedTmrCtrl; numOfTmrCtrl--; unusedTmrCtrl = ctrl; - taosThreadMutexUnlock(&tmrCtrlMutex); + (void)taosThreadMutexUnlock(&tmrCtrlMutex); tmrDebug("time controller's tmr ctrl size: %d", numOfTmrCtrl); if (numOfTmrCtrl <= 0) { diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index 993716f4df..885813f527 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -120,7 +120,7 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { return NULL; } - taosThreadMutexLock(&pool->mutex); + (void)taosThreadMutexLock(&pool->mutex); taosSetQueueFp(queue, fp, NULL); taosAddIntoQset(pool->qset, queue, ahandle); @@ -146,7 +146,7 @@ STaosQueue *tQWorkerAllocQueue(SQWorkerPool *pool, void *ahandle, FItem fp) { } while (pool->num < pool->min); } - taosThreadMutexUnlock(&pool->mutex); + (void)taosThreadMutexUnlock(&pool->mutex); uInfo("worker:%s, queue:%p is allocated, ahandle:%p", pool->name, queue, ahandle); return queue; @@ -251,7 +251,7 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem return NULL; } - taosThreadMutexLock(&pool->mutex); + (void)taosThreadMutexLock(&pool->mutex); taosSetQueueFp(queue, fp, NULL); taosAddIntoQset(pool->qset, queue, ahandle); @@ -267,7 +267,7 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem uError("worker:%s:%d failed to create", pool->name, curWorkerNum); taosMemoryFree(worker); taosCloseQueue(queue); - taosThreadMutexUnlock(&pool->mutex); + (void)taosThreadMutexUnlock(&pool->mutex); terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -294,7 +294,7 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem curWorkerNum++; } - taosThreadMutexUnlock(&pool->mutex); + (void)taosThreadMutexUnlock(&pool->mutex); uInfo("worker:%s, queue:%p is allocated, ahandle:%p", pool->name, queue, ahandle); return queue; @@ -393,7 +393,7 @@ static void *tWWorkerThreadFp(SWWorker *worker) { } STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) { - taosThreadMutexLock(&pool->mutex); + (void)taosThreadMutexLock(&pool->mutex); SWWorker *worker = pool->workers + pool->nextId; int32_t code = -1; STaosQueue *queue; @@ -427,7 +427,7 @@ STaosQueue *tWWorkerAllocQueue(SWWorkerPool *pool, void *ahandle, FItems fp) { } _OVER: - taosThreadMutexUnlock(&pool->mutex); + (void)taosThreadMutexUnlock(&pool->mutex); if (code) { if (queue != NULL) taosCloseQueue(queue); @@ -675,9 +675,9 @@ static bool tQueryAutoQWorkerTrySignalWaitingAfterBlock(void *p) { while (waiting > 0) { int32_t waitingNew = atomic_val_compare_exchange_32(&pPool->waitingAfterBlockN, waiting, waiting - 1); if (waitingNew == waiting) { - taosThreadMutexLock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); taosThreadCondSignal(&pPool->waitingAfterBlockCond); - taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); ret = true; break; } @@ -693,9 +693,9 @@ static bool tQueryAutoQWorkerTrySignalWaitingBeforeProcess(void *p) { while (waiting > 0) { int32_t waitingNew = atomic_val_compare_exchange_32(&pPool->waitingBeforeProcessMsgN, waiting, waiting - 1); if (waitingNew == waiting) { - taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); taosThreadCondSignal(&pPool->waitingBeforeProcessMsgCond); - taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); ret = true; break; } @@ -731,18 +731,18 @@ static int32_t tQueryAutoQWorkerWaitingCheck(SQueryAutoQWorkerPool *pPool) { } } // to wait for process - taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); atomic_fetch_add_32(&pPool->waitingBeforeProcessMsgN, 1); if (!pPool->exit) taosThreadCondWait(&pPool->waitingBeforeProcessMsgCond, &pPool->waitingBeforeProcessMsgLock); // recovered from waiting - taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); return TSDB_CODE_SUCCESS; } bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQWorker *pWorker) { if (tQueryAutoQWorkerTrySignalWaitingAfterBlock(pPool) || tQueryAutoQWorkerTrySignalWaitingBeforeProcess(pPool) || tQueryAutoQWorkerTryDecActive(pPool, pPool->num)) { - taosThreadMutexLock(&pPool->poolLock); + (void)taosThreadMutexLock(&pPool->poolLock); SListNode *pNode = listNode(pWorker); tdListPopNode(pPool->workers, pNode); // reclaim some workers @@ -757,29 +757,29 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ taosMemoryFree(head); } tdListAppendNode(pPool->exitedWorkers, pNode); - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); return false; } // put back to backup pool tdListAppendNode(pPool->backupWorkers, pNode); - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); // start to wait at backup cond - taosThreadMutexLock(&pPool->backupLock); + (void)taosThreadMutexLock(&pPool->backupLock); atomic_fetch_add_32(&pPool->backupNum, 1); if (!pPool->exit) taosThreadCondWait(&pPool->backupCond, &pPool->backupLock); - taosThreadMutexUnlock(&pPool->backupLock); + (void)taosThreadMutexUnlock(&pPool->backupLock); // recovered from backup - taosThreadMutexLock(&pPool->poolLock); + (void)taosThreadMutexLock(&pPool->poolLock); if (pPool->exit) { - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); return false; } tdListPopNode(pPool->backupWorkers, pNode); tdListAppendNode(pPool->workers, pNode); - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); return true; } else { @@ -819,7 +819,7 @@ int32_t tQueryAutoQWorkerInit(SQueryAutoQWorkerPool *pool) { } void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { - taosThreadMutexLock(&pPool->poolLock); + (void)taosThreadMutexLock(&pPool->poolLock); pPool->exit = true; int32_t size = listNEles(pPool->workers); for (int32_t i = 0; i < size; ++i) { @@ -829,31 +829,31 @@ void tQueryAutoQWorkerCleanup(SQueryAutoQWorkerPool *pPool) { for (int32_t i = 0; i < size; ++i) { taosQsetThreadResume(pPool->qset); } - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); - taosThreadMutexLock(&pPool->backupLock); + (void)taosThreadMutexLock(&pPool->backupLock); taosThreadCondBroadcast(&pPool->backupCond); - taosThreadMutexUnlock(&pPool->backupLock); + (void)taosThreadMutexUnlock(&pPool->backupLock); - taosThreadMutexLock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); taosThreadCondBroadcast(&pPool->waitingAfterBlockCond); - taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); - taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexLock(&pPool->waitingBeforeProcessMsgLock); taosThreadCondBroadcast(&pPool->waitingBeforeProcessMsgCond); - taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); + (void)taosThreadMutexUnlock(&pPool->waitingBeforeProcessMsgLock); int32_t idx = 0; SQueryAutoQWorker *worker = NULL; while (true) { - taosThreadMutexLock(&pPool->poolLock); + (void)taosThreadMutexLock(&pPool->poolLock); if (listNEles(pPool->workers) == 0) { - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); break; } SListNode *pNode = tdListPopHead(pPool->workers); worker = (SQueryAutoQWorker *)pNode->data; - taosThreadMutexUnlock(&pPool->poolLock); + (void)taosThreadMutexUnlock(&pPool->poolLock); if (worker && taosCheckPthreadValid(worker->thread)) { taosThreadJoin(worker->thread, NULL); taosThreadClear(&worker->thread); @@ -905,7 +905,7 @@ STaosQueue *tQueryAutoQWorkerAllocQueue(SQueryAutoQWorkerPool *pool, void *ahand return NULL; } - taosThreadMutexLock(&pool->poolLock); + (void)taosThreadMutexLock(&pool->poolLock); taosSetQueueFp(queue, fp, NULL); taosAddIntoQset(pool->qset, queue, ahandle); SQueryAutoQWorker worker = {0}; @@ -944,7 +944,7 @@ STaosQueue *tQueryAutoQWorkerAllocQueue(SQueryAutoQWorkerPool *pool, void *ahand } while (pool->num < pool->min); } - taosThreadMutexUnlock(&pool->poolLock); + (void)taosThreadMutexUnlock(&pool->poolLock); uInfo("worker:%s, queue:%p is allocated, ahandle:%p", pool->name, queue, ahandle); return queue; @@ -968,15 +968,15 @@ static int32_t tQueryAutoQWorkerAddWorker(SQueryAutoQWorkerPool *pool) { SQueryAutoQWorker worker = {0}; worker.pool = pool; worker.backupIdx = -1; - taosThreadMutexLock(&pool->poolLock); + (void)taosThreadMutexLock(&pool->poolLock); worker.id = listNEles(pool->workers); SListNode *pNode = tdListAdd(pool->workers, &worker); if (!pNode) { - taosThreadMutexUnlock(&pool->poolLock); + (void)taosThreadMutexUnlock(&pool->poolLock); terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - taosThreadMutexUnlock(&pool->poolLock); + (void)taosThreadMutexUnlock(&pool->poolLock); pWorker = (SQueryAutoQWorker *)pNode->data; TdThreadAttr thAttr; @@ -1015,10 +1015,10 @@ static int32_t tQueryAutoQWorkerRecoverFromBlocking(void *p) { return TSDB_CODE_SUCCESS; } } - taosThreadMutexLock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexLock(&pPool->waitingAfterBlockLock); atomic_fetch_add_32(&pPool->waitingAfterBlockN, 1); if (!pPool->exit) taosThreadCondWait(&pPool->waitingAfterBlockCond, &pPool->waitingAfterBlockLock); - taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); + (void)taosThreadMutexUnlock(&pPool->waitingAfterBlockLock); if (pPool->exit) return TSDB_CODE_QRY_QWORKER_QUIT; return TSDB_CODE_SUCCESS; } diff --git a/tests/script/tsim/stream/session0.sim b/tests/script/tsim/stream/session0.sim index 38adae4261..0d92070d10 100644 --- a/tests/script/tsim/stream/session0.sim +++ b/tests/script/tsim/stream/session0.sim @@ -189,11 +189,11 @@ run tsim/stream/checkTaskStatus.sim sql insert into t2 values(1648791213001,1,1,3,1.0,1); sql insert into t2 values(1648791213002,2,2,6,3.4,2); sql insert into t2 values(1648791213003,4,9,3,4.8,3); -sql insert into t2 values(1648791233003,3,4,3,2.1,4); -sql insert into t2 values(1648791233004,3,5,3,3.4,5); -sql insert into t2 values(1648791233005,3,6,3,7.6,6); -# +sql insert into t2 values(1648791233003,3,4,3,2.1,4) (1648791233004,3,5,3,3.4,5) (1648791233005,3,6,3,7.6,6); + +sleep 1000 + sql insert into t2 values(1648791223003,20,7,3,10.1,7); $loop_count = 0