Cleanup: sentinel config, latency extra time() (#8810)

This commit is contained in:
Huang Zhw 2021-05-09 23:45:45 +08:00 committed by GitHub
parent d32fd31588
commit 4d4db9797f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 34 deletions

View File

@ -137,7 +137,7 @@ void latencyAddSample(const char *event, mstime_t latency) {
return; return;
} }
ts->samples[ts->idx].time = time(NULL); ts->samples[ts->idx].time = now;
ts->samples[ts->idx].latency = latency; ts->samples[ts->idx].latency = latency;
ts->idx++; ts->idx++;

View File

@ -1845,43 +1845,29 @@ void loadSentinelConfigFromQueue(void) {
listNode *ln; listNode *ln;
int linenum = 0; int linenum = 0;
sds line = NULL; sds line = NULL;
unsigned int j;
/* if there is no sentinel_config entry, we can return immediately */ /* if there is no sentinel_config entry, we can return immediately */
if (server.sentinel_config == NULL) return; if (server.sentinel_config == NULL) return;
/* loading from pre monitor config queue first to avoid dependency issues */ list *sentinel_configs[3] = {
listRewind(server.sentinel_config->pre_monitor_cfg,&li); server.sentinel_config->pre_monitor_cfg,
while((ln = listNext(&li))) { server.sentinel_config->monitor_cfg,
struct sentinelLoadQueueEntry *entry = ln->value; server.sentinel_config->post_monitor_cfg
err = sentinelHandleConfiguration(entry->argv,entry->argc); };
if (err) { /* loading from pre monitor config queue first to avoid dependency issues
linenum = entry->linenum; * loading from monitor config queue
line = entry->line; * loading from the post monitor config queue */
goto loaderr; for (j = 0; j < sizeof(sentinel_configs) / sizeof(sentinel_configs[0]); j++) {
} listRewind(sentinel_configs[j],&li);
} while((ln = listNext(&li))) {
struct sentinelLoadQueueEntry *entry = ln->value;
/* loading from monitor config queue */ err = sentinelHandleConfiguration(entry->argv,entry->argc);
listRewind(server.sentinel_config->monitor_cfg,&li); if (err) {
while((ln = listNext(&li))) { linenum = entry->linenum;
struct sentinelLoadQueueEntry *entry = ln->value; line = entry->line;
err = sentinelHandleConfiguration(entry->argv,entry->argc); goto loaderr;
if (err) { }
linenum = entry->linenum;
line = entry->line;
goto loaderr;
}
}
/* loading from the post monitor config queue */
listRewind(server.sentinel_config->post_monitor_cfg,&li);
while((ln = listNext(&li))) {
struct sentinelLoadQueueEntry *entry = ln->value;
err = sentinelHandleConfiguration(entry->argv,entry->argc);
if (err) {
linenum = entry->linenum;
line = entry->line;
goto loaderr;
} }
} }