Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Retry vde_send() when it returns ENOBUFS
Browse files Browse the repository at this point in the history
Same issue as virtualsquare/vde-2#35

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Dec 7, 2021
1 parent 8aeb9b3 commit fe2ca94
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <assert.h>
#include <errno.h>
#include <sched.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -119,12 +121,20 @@ static void _on_vmnet_packets_available(interface_ref iface, int64_t buf_count,
received_count, buf_count);
for (int i = 0; i < received_count; i++) {
DEBUGF("[Handler i=%d] Sending to VDE: %ld bytes", i, pdv[i].vm_pkt_size);
ssize_t written =
while (1) {
ssize_t written =
vde_send(vdeconn, pdv[i].vm_pkt_iov->iov_base, pdv[i].vm_pkt_size, 0);
DEBUGF("[Handler i=%d] Sent to VDE: %ld bytes", i, written);
if (written != (ssize_t)pdv[i].vm_pkt_size) {
perror("vde_send");
goto done;
if (written < 0 && errno == ENOBUFS) {
DEBUGF("[Handler i=%d] No buffers available, trying again", i);
sched_yield();
continue;
}
DEBUGF("[Handler i=%d] Sent to VDE: %ld bytes", i, written);
if (written != (ssize_t)pdv[i].vm_pkt_size) {
perror("vde_send");
goto done;
}
break;
}
}
done:
Expand Down

0 comments on commit fe2ca94

Please sign in to comment.