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;