From 6ba612ef6e056de02cd85ae801c3ac3fe456014a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Machado?= Date: Fri, 3 Apr 2026 14:39:26 +0100 Subject: [PATCH] logfile fflush() timer --- code/bngblaster/src/bbl.c | 14 ++++++++++++++ code/bngblaster/src/bbl_ctx.h | 1 + 2 files changed, 15 insertions(+) diff --git a/code/bngblaster/src/bbl.c b/code/bngblaster/src/bbl.c index 3245b4eb..d1212c12 100644 --- a/code/bngblaster/src/bbl.c +++ b/code/bngblaster/src/bbl.c @@ -395,6 +395,15 @@ bbl_ctrl_job(timer_s *timer) } } +void +logfile_fflush_job(timer_s *timer) +{ + UNUSED(timer); + if(g_log_fp) { + fflush(g_log_fp); + } +} + /** * @brief BNG BLASTER MAIN FUNCTION * @@ -520,6 +529,11 @@ main(int argc, char *argv[]) /* Open logfile. */ log_open(); + if(g_log_fp) { + timer_add_periodic(&g_ctx->timer_root, &g_ctx->logfile_fflush_timer, + "logfile fflush()", 0, 100 * MSEC, g_ctx, + &logfile_fflush_job); + } /* Init config. */ bbl_config_init_defaults(); diff --git a/code/bngblaster/src/bbl_ctx.h b/code/bngblaster/src/bbl_ctx.h index 5a358dce..0ad090e2 100644 --- a/code/bngblaster/src/bbl_ctx.h +++ b/code/bngblaster/src/bbl_ctx.h @@ -19,6 +19,7 @@ typedef struct bbl_ctx_ struct timer_ *smear_timer; struct timer_ *stats_timer; struct timer_ *keyboard_timer; + struct timer_ *logfile_fflush_timer; struct timer_ *tcp_timer; struct timer_ *fragmentation_timer;