未验证 提交 1cdc5afe 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #10552 from taosdata/feature/config

fix crash while acquire connection
...@@ -940,8 +940,13 @@ bool taosCacheIterNext(SCacheIter* pIter) { ...@@ -940,8 +940,13 @@ bool taosCacheIterNext(SCacheIter* pIter) {
pIter->pCurrent[i] = NULL; pIter->pCurrent[i] = NULL;
} }
while(1) { while (1) {
SCacheEntry *pEntry = &pCacheObj->pEntryList[++pIter->entryIndex]; pIter->entryIndex++;
if (pIter->entryIndex >= pCacheObj->capacity) {
return false;
}
SCacheEntry *pEntry = &pCacheObj->pEntryList[pIter->entryIndex];
taosRLockLatch(&pEntry->latch); taosRLockLatch(&pEntry->latch);
if (pEntry->num == 0) { if (pEntry->num == 0) {
......
...@@ -17,12 +17,10 @@ ...@@ -17,12 +17,10 @@
#include "tlog.h" #include "tlog.h"
#include "tutil.h" #include "tutil.h"
#define LOG_MAX_LINE_SIZE (1000) #define LOG_MAX_LINE_SIZE (1024)
#define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 10) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3)
#define LOG_MAX_LINE_CONTENT_SIZE (LOG_MAX_LINE_SIZE - 100)
#define LOG_MAX_LINE_DUMP_SIZE (65 * 1024) #define LOG_MAX_LINE_DUMP_SIZE (65 * 1024)
#define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 10) #define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 3)
#define LOG_MAX_LINE_DUMP_CONTENT_SIZE (LOG_MAX_LINE_DUMP_SIZE - 100)
#define LOG_FILE_NAME_LEN 300 #define LOG_FILE_NAME_LEN 300
#define LOG_DEFAULT_BUF_SIZE (20 * 1024 * 1024) // 20MB #define LOG_DEFAULT_BUF_SIZE (20 * 1024 * 1024) // 20MB
...@@ -401,7 +399,7 @@ void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char ...@@ -401,7 +399,7 @@ void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char
if (!osLogSpaceAvailable()) return; if (!osLogSpaceAvailable()) return;
va_list argpointer; va_list argpointer;
char buffer[LOG_MAX_LINE_BUFFER_SIZE] = {0}; char buffer[LOG_MAX_LINE_BUFFER_SIZE];
int32_t len; int32_t len;
struct tm Tm, *ptm; struct tm Tm, *ptm;
struct timeval timeSecs; struct timeval timeSecs;
...@@ -416,17 +414,7 @@ void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char ...@@ -416,17 +414,7 @@ void taosPrintLog(const char *flags, ELogLevel level, int32_t dflag, const char
len += sprintf(buffer + len, "%s", flags); len += sprintf(buffer + len, "%s", flags);
va_start(argpointer, format); va_start(argpointer, format);
int32_t writeLen = vsnprintf(buffer + len, LOG_MAX_LINE_CONTENT_SIZE, format, argpointer); len += vsnprintf(buffer + len, LOG_MAX_LINE_BUFFER_SIZE - len, format, argpointer);
if (writeLen <= 0) {
char tmp[LOG_MAX_LINE_DUMP_BUFFER_SIZE] = {0};
writeLen = vsnprintf(tmp, LOG_MAX_LINE_DUMP_CONTENT_SIZE, format, argpointer);
strncpy(buffer + len, tmp, LOG_MAX_LINE_CONTENT_SIZE);
len += LOG_MAX_LINE_CONTENT_SIZE;
} else if (writeLen >= LOG_MAX_LINE_CONTENT_SIZE) {
len += LOG_MAX_LINE_CONTENT_SIZE;
} else {
len += writeLen;
}
va_end(argpointer); va_end(argpointer);
if (len > LOG_MAX_LINE_SIZE) len = LOG_MAX_LINE_SIZE; if (len > LOG_MAX_LINE_SIZE) len = LOG_MAX_LINE_SIZE;
...@@ -497,7 +485,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons ...@@ -497,7 +485,7 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons
len += sprintf(buffer + len, "%s", flags); len += sprintf(buffer + len, "%s", flags);
va_start(argpointer, format); va_start(argpointer, format);
len += vsnprintf(buffer + len, LOG_MAX_LINE_DUMP_CONTENT_SIZE, format, argpointer); len += vsnprintf(buffer + len, LOG_MAX_LINE_DUMP_BUFFER_SIZE, format, argpointer);
va_end(argpointer); va_end(argpointer);
if (len > LOG_MAX_LINE_DUMP_SIZE) len = LOG_MAX_LINE_DUMP_SIZE; if (len > LOG_MAX_LINE_DUMP_SIZE) len = LOG_MAX_LINE_DUMP_SIZE;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册