From b6c22e63e11aa3ac69c12fa726ec96ef383a21af Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Sat, 20 Aug 2022 11:05:09 +0300 Subject: [PATCH] NET_SOFTERROR on UDP send EAGAIN/EINTR errno if no data was sent --- src/iperf_udp.c | 7 +++++-- src/net.c | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/iperf_udp.c b/src/iperf_udp.c index b697c9729..45e2e6454 100644 --- a/src/iperf_udp.c +++ b/src/iperf_udp.c @@ -250,8 +250,11 @@ iperf_udp_send(struct iperf_stream *sp) r = Nwrite(sp->socket, sp->buffer, size, Pudp); - if (r < 0) - return r; + if (r < 0) { + if (r == NET_SOFTERROR && sp->test->debug_level >= DEBUG_LEVEL_INFO) + printf("UDP send failed on NET_SOFTERROR. errno=%s\n", strerror(errno)); + return r; + } sp->result->bytes_sent += r; sp->result->bytes_sent_this_interval += r; diff --git a/src/net.c b/src/net.c index 1a88155bc..caeca3422 100644 --- a/src/net.c +++ b/src/net.c @@ -409,12 +409,14 @@ Nwrite(int fd, const char *buf, size_t count, int prot) #if (EAGAIN != EWOULDBLOCK) case EWOULDBLOCK: #endif + if (count == nleft) + return NET_SOFTERROR; return count - nleft; - case ENOBUFS: - return NET_SOFTERROR; + case ENOBUFS : + return NET_SOFTERROR; - default: + default: return NET_HARDERROR; } } else if (r == 0)