Skip to content

Commit

Permalink
In vde_switch retry send() when it returns ENOBUFS on Darwin and FreeBSD
Browse files Browse the repository at this point in the history
On these platforms ENOBUFS can be returned by send() even on blocking
sockets.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Dec 7, 2021
1 parent 534a094 commit 5bb8951
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/vde_switch/datasock.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <libgen.h>
#include <sched.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
Expand Down Expand Up @@ -87,8 +88,14 @@ union request {

static int send_datasock(int fd_ctl, int fd_data, void *packet, int len, int port)
{
if (send(fd_data, packet, len, 0) < 0) {
while (send(fd_data, packet, len, 0) < 0) {
int rv=errno;
#if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
if(rv == ENOBUFS) {
sched_yield();
continue;
}
#endif
if(rv != EAGAIN && rv != EWOULDBLOCK)
printlog(LOG_WARNING,"send_sockaddr port %d: %s",port,strerror(errno));
else
Expand Down

0 comments on commit 5bb8951

Please sign in to comment.