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

Merge pull request #10550 from taosdata/feature/config

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