Skip to content

Commit 6ba612e

Browse files
committed
logfile fflush() timer
1 parent 0704d51 commit 6ba612e

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

code/bngblaster/src/bbl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@ bbl_ctrl_job(timer_s *timer)
395395
}
396396
}
397397

398+
void
399+
logfile_fflush_job(timer_s *timer)
400+
{
401+
UNUSED(timer);
402+
if(g_log_fp) {
403+
fflush(g_log_fp);
404+
}
405+
}
406+
398407
/**
399408
* @brief BNG BLASTER MAIN FUNCTION
400409
*
@@ -520,6 +529,11 @@ main(int argc, char *argv[])
520529

521530
/* Open logfile. */
522531
log_open();
532+
if(g_log_fp) {
533+
timer_add_periodic(&g_ctx->timer_root, &g_ctx->logfile_fflush_timer,
534+
"logfile fflush()", 0, 100 * MSEC, g_ctx,
535+
&logfile_fflush_job);
536+
}
523537

524538
/* Init config. */
525539
bbl_config_init_defaults();

code/bngblaster/src/bbl_ctx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ typedef struct bbl_ctx_
1919
struct timer_ *smear_timer;
2020
struct timer_ *stats_timer;
2121
struct timer_ *keyboard_timer;
22+
struct timer_ *logfile_fflush_timer;
2223

2324
struct timer_ *tcp_timer;
2425
struct timer_ *fragmentation_timer;

0 commit comments

Comments
 (0)