Skip to content

Commit

Permalink
Cleanup: sentinel config, latency extra time() (redis#8810)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzhw authored May 9, 2021
1 parent d32fd31 commit 4d4db97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/latency.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void latencyAddSample(const char *event, mstime_t latency) {
return;
}

ts->samples[ts->idx].time = time(NULL);
ts->samples[ts->idx].time = now;
ts->samples[ts->idx].latency = latency;

ts->idx++;
Expand Down
52 changes: 19 additions & 33 deletions src/sentinel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1845,43 +1845,29 @@ void loadSentinelConfigFromQueue(void) {
listNode *ln;
int linenum = 0;
sds line = NULL;
unsigned int j;

/* if there is no sentinel_config entry, we can return immediately */
if (server.sentinel_config == NULL) return;

/* loading from pre monitor config queue first to avoid dependency issues */
listRewind(server.sentinel_config->pre_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;
}
}

/* loading from monitor config queue */
listRewind(server.sentinel_config->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;
}
}

/* 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;
list *sentinel_configs[3] = {
server.sentinel_config->pre_monitor_cfg,
server.sentinel_config->monitor_cfg,
server.sentinel_config->post_monitor_cfg
};
/* loading from pre monitor config queue first to avoid dependency issues
* loading from monitor config queue
* loading from the post monitor config queue */
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;
err = sentinelHandleConfiguration(entry->argv,entry->argc);
if (err) {
linenum = entry->linenum;
line = entry->line;
goto loaderr;
}
}
}

Expand Down

0 comments on commit 4d4db97

Please sign in to comment.