Skip to content

Commit 19ec5a3

Browse files
pwhelanedsiper
authored andcommitted
reload: refactor watchdog to be preemptable on windows.
Signed-off-by: Phillip Whelan <[email protected]>
1 parent 5fff944 commit 19ec5a3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/flb_reload.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,16 @@ struct flb_reload_watchdog_ctx {
387387

388388
static void *hot_reload_watchdog_thread(void *arg)
389389
{
390+
int loop_sleep;
390391
struct flb_reload_watchdog_ctx *ctx = (struct flb_reload_watchdog_ctx *)arg;
391392

392393
/* Set async cancellation type for (mostly) immediate response to pthread_cancel */
393394
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
394395

395-
flb_time_msleep(ctx->timeout_seconds * 1000);
396+
/* loop for each sleep in a busy pattern to avoid delaying flb_reload() */
397+
for (loop_sleep = 0; loop_sleep < ctx->timeout_seconds*10; loop_sleep++) {
398+
flb_time_msleep(100);
399+
}
396400

397401
flb_error("[hot_reload_watchdog] Hot reload timeout exceeded (%d seconds), "
398402
"aborting to prevent indefinite hang", ctx->timeout_seconds);
@@ -621,7 +625,9 @@ int flb_reload(flb_ctx_t *ctx, struct flb_cf *cf_opts)
621625
new_config->hot_reload_succeeded = FLB_TRUE;
622626

623627
/* Cancel the watchdog thread since reload completed successfully */
628+
flb_debug("[reload] cleanup watchdog");
624629
flb_reload_watchdog_cleanup(watchdog_ctx);
625630

631+
flb_info("[reload] successful reload done.");
626632
return 0;
627633
}

0 commit comments

Comments
 (0)