From 6a62b42024533032f76a746423bf3b9603d8e9dc Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Fri, 19 Aug 2022 16:18:32 +0300 Subject: [PATCH] NET_SOFTERROR on UDP send EAGAIN/EINTR errno if no data was sent --- src/iperf_udp.c | 11 +++++++---- src/net.c | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/iperf_udp.c b/src/iperf_udp.c index b697c9729..85ab494ce 100644 --- a/src/iperf_udp.c +++ b/src/iperf_udp.c @@ -218,8 +218,6 @@ iperf_udp_send(struct iperf_stream *sp) iperf_time_now(&before); - ++sp->packet_count; - if (sp->test->udp_counters_64bit) { uint32_t sec, usec; @@ -250,8 +248,13 @@ 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->packet_count; sp->result->bytes_sent += r; sp->result->bytes_sent_this_interval += r; diff --git a/src/net.c b/src/net.c index 1a88155bc..b5c538207 100644 --- a/src/net.c +++ b/src/net.c @@ -409,12 +409,15 @@ Nwrite(int fd, const char *buf, size_t count, int prot) #if (EAGAIN != EWOULDBLOCK) case EWOULDBLOCK: #endif - return count - nleft; + if (count > nleft) + return count - nleft; + else + return NET_SOFTERROR; - case ENOBUFS: - return NET_SOFTERROR; + case ENOBUFS : + return NET_SOFTERROR; - default: + default: return NET_HARDERROR; } } else if (r == 0)