Skip to content

Commit c42c4ff

Browse files
committed
engine: Add a fallback mechanism when failing to set up an interval
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 6614f47 commit c42c4ff

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/flb_engine.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ static int flb_engine_flush_timer_reset(struct flb_config *config, double interv
279279
{
280280
struct mk_event *event;
281281
struct flb_time t_flush;
282+
double fallback_interval;
282283

283284
event = &config->event_flush;
285+
fallback_interval = config->flush_adaptive_current_interval;
284286

285287
if (event->status != MK_EVENT_NONE) {
286288
mk_event_timeout_destroy(config->evl, event);
@@ -296,7 +298,20 @@ static int flb_engine_flush_timer_reset(struct flb_config *config, double interv
296298

297299
if (config->flush_fd == -1) {
298300
flb_utils_error(FLB_ERR_CFG_FLUSH_CREATE);
299-
return -1;
301+
302+
if (fallback_interval > 0.0 &&
303+
fabs(fallback_interval - interval) > DBL_EPSILON) {
304+
flb_time_from_double(&t_flush, fallback_interval);
305+
config->flush_fd = mk_event_timeout_create(config->evl,
306+
t_flush.tm.tv_sec,
307+
t_flush.tm.tv_nsec,
308+
event);
309+
event->priority = FLB_ENGINE_PRIORITY_FLUSH;
310+
}
311+
312+
if (config->flush_fd == -1) {
313+
return -1;
314+
}
300315
}
301316

302317
return 0;

0 commit comments

Comments
 (0)