minor changes
This commit is contained in:
parent
5367ca7f2a
commit
42e243813e
|
@ -34,11 +34,11 @@ typedef struct SMonInfo {
|
|||
} SMonInfo;
|
||||
|
||||
typedef struct {
|
||||
pthread_rwlock_t rwlock;
|
||||
SArray *logs; // array of SMonLogItem
|
||||
int32_t maxLogs;
|
||||
const char *server;
|
||||
uint16_t port;
|
||||
pthread_mutex_t lock;
|
||||
SArray *logs; // array of SMonLogItem
|
||||
int32_t maxLogs;
|
||||
const char *server;
|
||||
uint16_t port;
|
||||
} SMonitor;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue