diff options
Diffstat (limited to 'trafgen.c')
-rw-r--r-- | trafgen.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -127,11 +127,24 @@ static void signal_handler(int number) static void timer_elapsed(int number) { - int ret; + int ret = pull_and_flush_tx_ring(sock); + if (unlikely(ret < 0)) { + /* We could hit EBADF if the socket has been closed before + * the timer was triggered. + */ + if (errno != EBADF && errno != ENOBUFS) + panic("Flushing TX_RING failed: %s!\n", strerror(errno)); + } set_itimer_interval_value(&itimer, 0, interval); + setitimer(ITIMER_REAL, &itimer, NULL); +} - ret = pull_and_flush_tx_ring(sock); +static void timer_purge(void) +{ + int ret; + + ret = pull_and_flush_tx_ring_wait(sock); if (unlikely(ret < 0)) { /* We could hit EBADF if the socket has been closed before * the timer was triggered. @@ -140,6 +153,7 @@ static void timer_elapsed(int number) panic("Flushing TX_RING failed: %s!\n", strerror(errno)); } + set_itimer_interval_value(&itimer, 0, 0); setitimer(ITIMER_REAL, &itimer, NULL); } @@ -669,6 +683,8 @@ static void xmit_fastpath_or_die(struct ctx *ctx, int cpu, unsigned long orig_nu bug_on(gettimeofday(&end, NULL)); timersub(&end, &start, &diff); + timer_purge(); + destroy_tx_ring(sock, &tx_ring); stats[cpu].tx_packets = tx_packets; |