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

Merge pull request #10550 from taosdata/feature/config

minor changes
...@@ -34,11 +34,11 @@ typedef struct SMonInfo { ...@@ -34,11 +34,11 @@ typedef struct SMonInfo {
} SMonInfo; } SMonInfo;
typedef struct { typedef struct {
pthread_rwlock_t rwlock; pthread_mutex_t lock;
SArray *logs; // array of SMonLogItem SArray *logs; // array of SMonLogItem
int32_t maxLogs; int32_t maxLogs;
const char *server; const char *server;
uint16_t port; uint16_t port;
} SMonitor; } SMonitor;
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
static SMonitor tsMonitor = {0}; static SMonitor tsMonitor = {0};
void monRecordLog(int64_t ts, ELogLevel level, const char *content) { void monRecordLog(int64_t ts, ELogLevel level, const char *content) {
pthread_rwlock_rdlock(&tsMonitor.rwlock); pthread_mutex_lock(&tsMonitor.lock);
int32_t size = taosArrayGetSize(tsMonitor.logs); int32_t size = taosArrayGetSize(tsMonitor.logs);
if (size >= tsMonitor.maxLogs) { if (size >= tsMonitor.maxLogs) {
uInfo("too many logs for monitor"); uInfo("too many logs for monitor");
...@@ -34,7 +34,7 @@ void monRecordLog(int64_t ts, ELogLevel level, const char *content) { ...@@ -34,7 +34,7 @@ void monRecordLog(int64_t ts, ELogLevel level, const char *content) {
tstrncpy(pItem->content, content, sizeof(item.content)); tstrncpy(pItem->content, content, sizeof(item.content));
} }
} }
pthread_rwlock_unlock(&tsMonitor.rwlock); pthread_mutex_unlock(&tsMonitor.lock);
} }
int32_t monInit(const SMonCfg *pCfg) { int32_t monInit(const SMonCfg *pCfg) {
...@@ -48,14 +48,14 @@ int32_t monInit(const SMonCfg *pCfg) { ...@@ -48,14 +48,14 @@ int32_t monInit(const SMonCfg *pCfg) {
tsMonitor.server = pCfg->server; tsMonitor.server = pCfg->server;
tsMonitor.port = pCfg->port; tsMonitor.port = pCfg->port;
tsLogFp = monRecordLog; tsLogFp = monRecordLog;
pthread_rwlock_init(&tsMonitor.rwlock, NULL); pthread_mutex_init(&tsMonitor.lock, NULL);
return 0; return 0;
} }
void monCleanup() { void monCleanup() {
taosArrayDestroy(tsMonitor.logs); taosArrayDestroy(tsMonitor.logs);
tsMonitor.logs = NULL; tsMonitor.logs = NULL;
pthread_rwlock_wrlock(&tsMonitor.rwlock); pthread_mutex_destroy(&tsMonitor.lock);
} }
SMonInfo *monCreateMonitorInfo() { SMonInfo *monCreateMonitorInfo() {
...@@ -65,10 +65,10 @@ SMonInfo *monCreateMonitorInfo() { ...@@ -65,10 +65,10 @@ SMonInfo *monCreateMonitorInfo() {
return NULL; return NULL;
} }
pthread_rwlock_wrlock(&tsMonitor.rwlock); pthread_mutex_lock(&tsMonitor.lock);
pMonitor->logs = taosArrayDup(tsMonitor.logs); pMonitor->logs = taosArrayDup(tsMonitor.logs);
taosArrayClear(tsMonitor.logs); taosArrayClear(tsMonitor.logs);
pthread_rwlock_unlock(&tsMonitor.rwlock); pthread_mutex_unlock(&tsMonitor.lock);
pMonitor->pJson = tjsonCreateObject(); pMonitor->pJson = tjsonCreateObject();
if (pMonitor->pJson == NULL || pMonitor->logs == NULL) { if (pMonitor->pJson == NULL || pMonitor->logs == NULL) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册