Skip to content

Commit

Permalink
Merge pull request #59 from nokute78/nsec_support
Browse files Browse the repository at this point in the history
Engine: collector and in_head support high resolution interval (#48)
  • Loading branch information
edsiper committed Mar 21, 2016
2 parents 917d131 + 5637c73 commit 3937b7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions plugins/in_head/in_head.c
Expand Up @@ -107,20 +107,27 @@ static int in_head_config_read(struct flb_in_head_config *head_config,

/* interval settings */
pval = mk_rconf_section_get_key(section, "interval_sec", MK_RCONF_STR);
if (pval != NULL && atoi(pval) > 0) {
if (pval != NULL && atoi(pval) >= 0) {
head_config->interval_sec = atoi(pval);
}
else {
head_config->interval_sec = DEFAULT_INTERVAL_SEC;
}
pval = mk_rconf_section_get_key(section, "interval_nsec", MK_RCONF_STR);
if (pval != NULL && atoi(pval) > 0) {
if (pval != NULL && atoi(pval) >= 0) {
head_config->interval_nsec = atoi(pval);
}
else {
head_config->interval_nsec = DEFAULT_INTERVAL_NSEC;
}

if ( head_config->interval_sec <= 0 && head_config->interval_nsec <= 0){
/* Illegal settings. Override them. */
head_config->interval_sec = DEFAULT_INTERVAL_SEC;
head_config->interval_nsec = DEFAULT_INTERVAL_NSEC;
}


flb_trace("Head config: buf_size=%d path=%s",
head_config->buf_size, head_config->filepath);
flb_trace("Head config: interval_sec=%d interval_nsec=%d",
Expand Down
3 changes: 2 additions & 1 deletion src/flb_engine.c
Expand Up @@ -320,7 +320,8 @@ int flb_engine_start(struct flb_config *config)
if (collector->type == FLB_COLLECT_TIME) {
event->mask = MK_EVENT_EMPTY;
event->status = MK_EVENT_NONE;
fd = mk_event_timeout_create(evl, collector->seconds, 0, event);
fd = mk_event_timeout_create(evl, collector->seconds,
collector->nanoseconds, event);
if (fd == -1) {
continue;
}
Expand Down

0 comments on commit 3937b7e

Please sign in to comment.