summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-06-20 10:46:52 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-06-20 10:53:59 +0200
commit8d7b0c30a62ca50e0c104ed4aa600cfb24041161 (patch)
tree9e298be73c97352cacd52beebcbd3c5eb2dda52c /trafgen.c
parent6e3a87093dfcd8b4b62685e67b565d842c631da1 (diff)
trafgen: gracefully handle ENOBUFS on tx ring teardown
pull_and_flush_tx_ring_wait() in the exit path of xmit_fastpath_or_die() might return with errno ENOBUFS (due to the other CPU's processes concurrent access) but will eventually suceed. Thus retry pull_and_flush_tx_ring_wait() as in the main loop of xmit_fastpath_or_die(). Fixes #175 Reported-by: Eduardo Miravalls Sierra Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen.c')
-rw-r--r--trafgen.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/trafgen.c b/trafgen.c
index b40d362..5f3555a 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -743,7 +743,7 @@ static void xmit_fastpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned lon
{
int ifindex = dev_io_ifindex_get(ctx->dev_out);
uint8_t *out = NULL;
- unsigned int it = 0;
+ unsigned int it = 0, retry = 100;
unsigned long num = 1, i = 0;
size_t size = ring_size(dev_io_name_get(ctx->dev_out), ctx->reserve_size);
struct ring tx_ring;
@@ -812,7 +812,8 @@ static void xmit_fastpath_or_die(struct ctx *ctx, unsigned int cpu, unsigned lon
bug_on(gettimeofday(&end, NULL));
timersub(&end, &start, &diff);
- pull_and_flush_tx_ring_wait(sock);
+ while (pull_and_flush_tx_ring_wait(sock) < 0 && errno == ENOBUFS && retry-- > 0)
+ usleep(10000);
destroy_tx_ring(sock, &tx_ring);
stats[cpu].tx_packets = tx_packets;