提交 17b97e37 编写于 作者: S Shengliang Guan

invalid read

上级 29afc80f
...@@ -127,7 +127,7 @@ static void clientHandleResp(SCliConn* conn) { ...@@ -127,7 +127,7 @@ static void clientHandleResp(SCliConn* conn) {
// buf's mem alread translated to rpcMsg.pCont // buf's mem alread translated to rpcMsg.pCont
transClearBuffer(&conn->readBuf); transClearBuffer(&conn->readBuf);
SRpcMsg rpcMsg; SRpcMsg rpcMsg = {0};
rpcMsg.contLen = transContLenFromMsg(pHead->msgLen); rpcMsg.contLen = transContLenFromMsg(pHead->msgLen);
rpcMsg.pCont = transContFromHead((char*)pHead); rpcMsg.pCont = transContFromHead((char*)pHead);
rpcMsg.code = pHead->code; rpcMsg.code = pHead->code;
......
...@@ -366,11 +366,11 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy ...@@ -366,11 +366,11 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy
} }
SConfigItem *cfgGetItem(SConfig *pCfg, const char *name) { SConfigItem *cfgGetItem(SConfig *pCfg, const char *name) {
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; int32_t len = strlen(name);
memcpy(lowcaseName, name, CFG_NAME_MAX_LEN); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
strntolower(lowcaseName, name, CFG_NAME_MAX_LEN); strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len));
SConfigItem *pItem = taosHashGet(pCfg->hash, lowcaseName, strlen(lowcaseName) + 1); SConfigItem *pItem = taosHashGet(pCfg->hash, lowcaseName, len + 1);
if (pItem == NULL) { if (pItem == NULL) {
terrno = TSDB_CODE_CFG_NOT_FOUND; terrno = TSDB_CODE_CFG_NOT_FOUND;
} }
...@@ -386,11 +386,11 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) { ...@@ -386,11 +386,11 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) {
return -1; return -1;
} }
char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; int32_t len = strlen(name);
memcpy(lowcaseName, name, CFG_NAME_MAX_LEN); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0};
strntolower(lowcaseName, name, CFG_NAME_MAX_LEN); strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len));
if (taosHashPut(pCfg->hash, lowcaseName, strlen(lowcaseName) + 1, pItem, sizeof(SConfigItem)) != 0) { if (taosHashPut(pCfg->hash, lowcaseName, len + 1, pItem, sizeof(SConfigItem)) != 0) {
if (pItem->dtype == CFG_DTYPE_STRING) { if (pItem->dtype == CFG_DTYPE_STRING) {
free(pItem->str); free(pItem->str);
} }
......
...@@ -64,16 +64,17 @@ typedef struct { ...@@ -64,16 +64,17 @@ typedef struct {
pthread_mutex_t logMutex; pthread_mutex_t logMutex;
} SLogObj; } SLogObj;
int8_t tscEmbeddedInUtil = 0; static int8_t tsLogInited = 0;
static SLogObj tsLogObj = {.fileNum = 1};
int8_t tscEmbeddedInUtil = 0;
int32_t tsLogKeepDays = 0; int32_t tsLogKeepDays = 0;
bool tsAsyncLog = true; bool tsAsyncLog = true;
int8_t tsLogInited = 0; int32_t tsNumOfLogLines = 10000000;
int64_t asyncLogLostLines = 0; int64_t tsAsyncLogLostLines = 0;
int32_t writeInterval = LOG_DEFAULT_INTERVAL; int32_t tsWriteInterval = LOG_DEFAULT_INTERVAL;
// log // log
int32_t tsNumOfLogLines = 10000000;
int32_t dDebugFlag = 135; int32_t dDebugFlag = 135;
int32_t vDebugFlag = 135; int32_t vDebugFlag = 135;
int32_t mDebugFlag = 131; int32_t mDebugFlag = 131;
...@@ -95,13 +96,11 @@ int64_t dbgSmallWN = 0; ...@@ -95,13 +96,11 @@ int64_t dbgSmallWN = 0;
int64_t dbgBigWN = 0; int64_t dbgBigWN = 0;
int64_t dbgWSize = 0; int64_t dbgWSize = 0;
static SLogObj tsLogObj = {.fileNum = 1};
static void *taosAsyncOutputLog(void *param); static void *taosAsyncOutputLog(void *param);
static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen); static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen);
static SLogBuff *taosLogBuffNew(int32_t bufSize); static SLogBuff *taosLogBuffNew(int32_t bufSize);
static void taosCloseLogByFd(TdFilePtr pFile); static void taosCloseLogByFd(TdFilePtr pFile);
static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum); static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum);
extern void taosPrintCfg();
static int32_t taosCompressFile(char *srcFileName, char *destFileName); static int32_t taosCompressFile(char *srcFileName, char *destFileName);
static int32_t taosStartLog() { static int32_t taosStartLog() {
...@@ -125,7 +124,6 @@ int32_t taosInitLog(const char *logName, int maxFiles) { ...@@ -125,7 +124,6 @@ int32_t taosInitLog(const char *logName, int maxFiles) {
if (tsLogObj.logHandle == NULL) return -1; if (tsLogObj.logHandle == NULL) return -1;
if (taosOpenLogFile(fullName, tsNumOfLogLines, maxFiles) < 0) return -1; if (taosOpenLogFile(fullName, tsNumOfLogLines, maxFiles) < 0) return -1;
if (taosStartLog() < 0) return -1; if (taosStartLog() < 0) return -1;
tsLogInited = true;
return 0; return 0;
} }
...@@ -218,7 +216,6 @@ static void *taosThreadToOpenNewFile(void *param) { ...@@ -218,7 +216,6 @@ static void *taosThreadToOpenNewFile(void *param) {
uInfo(" new log file:%d is opened", tsLogObj.flag); uInfo(" new log file:%d is opened", tsLogObj.flag);
uInfo("=================================="); uInfo("==================================");
// taosPrintCfg();
taosKeepOldLog(keepName); taosKeepOldLog(keepName);
return NULL; return NULL;
...@@ -582,7 +579,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen) ...@@ -582,7 +579,7 @@ static int32_t taosPushLogBuffer(SLogBuff *tLogBuff, char *msg, int32_t msgLen)
if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) { if (remainSize <= msgLen || ((lostLine > 0) && (remainSize <= (msgLen + tmpBufLen)))) {
lostLine++; lostLine++;
asyncLogLostLines++; tsAsyncLogLostLines++;
pthread_mutex_unlock(&LOG_BUF_MUTEX(tLogBuff)); pthread_mutex_unlock(&LOG_BUF_MUTEX(tLogBuff));
return -1; return -1;
} }
...@@ -627,13 +624,13 @@ static void taosWriteLog(SLogBuff *tLogBuff) { ...@@ -627,13 +624,13 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
if (start == end) { if (start == end) {
dbgEmptyW++; dbgEmptyW++;
writeInterval = LOG_MAX_INTERVAL; tsWriteInterval = LOG_MAX_INTERVAL;
return; return;
} }
pollSize = taosGetLogRemainSize(tLogBuff, start, end); pollSize = taosGetLogRemainSize(tLogBuff, start, end);
if (pollSize < tLogBuff->minBuffSize) { if (pollSize < tLogBuff->minBuffSize) {
lastDuration += writeInterval; lastDuration += tsWriteInterval;
if (lastDuration < LOG_MAX_WAIT_MSEC) { if (lastDuration < LOG_MAX_WAIT_MSEC) {
break; break;
} }
...@@ -656,15 +653,15 @@ static void taosWriteLog(SLogBuff *tLogBuff) { ...@@ -656,15 +653,15 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
if (pollSize < tLogBuff->minBuffSize) { if (pollSize < tLogBuff->minBuffSize) {
dbgSmallWN++; dbgSmallWN++;
if (writeInterval < LOG_MAX_INTERVAL) { if (tsWriteInterval < LOG_MAX_INTERVAL) {
writeInterval += LOG_INTERVAL_STEP; tsWriteInterval += LOG_INTERVAL_STEP;
} }
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 3) { } else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 3) {
dbgBigWN++; dbgBigWN++;
writeInterval = LOG_MIN_INTERVAL; tsWriteInterval = LOG_MIN_INTERVAL;
} else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 4) { } else if (pollSize > LOG_BUF_SIZE(tLogBuff) / 4) {
if (writeInterval > LOG_MIN_INTERVAL) { if (tsWriteInterval > LOG_MIN_INTERVAL) {
writeInterval -= LOG_INTERVAL_STEP; tsWriteInterval -= LOG_INTERVAL_STEP;
} }
} }
...@@ -678,7 +675,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) { ...@@ -678,7 +675,7 @@ static void taosWriteLog(SLogBuff *tLogBuff) {
break; break;
} }
writeInterval = LOG_MIN_INTERVAL; tsWriteInterval = LOG_MIN_INTERVAL;
remainChecked = 1; remainChecked = 1;
} while (1); } while (1);
...@@ -689,7 +686,7 @@ static void *taosAsyncOutputLog(void *param) { ...@@ -689,7 +686,7 @@ static void *taosAsyncOutputLog(void *param) {
setThreadName("log"); setThreadName("log");
while (1) { while (1) {
taosMsleep(writeInterval); taosMsleep(tsWriteInterval);
// Polling the buffer // Polling the buffer
taosWriteLog(tLogBuff); taosWriteLog(tLogBuff);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册