From a67a4ca34951e9ee2c5f1ad33dd155f9f11bb758 Mon Sep 17 00:00:00 2001 From: quackerd Date: Fri, 7 Apr 2023 23:24:33 +0200 Subject: [PATCH] nsendfile --- src/iperf_tcp.c | 8 ++++---- src/net.c | 8 ++++---- src/net.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/iperf_tcp.c b/src/iperf_tcp.c index aaa33bf..925230c 100644 --- a/src/iperf_tcp.c +++ b/src/iperf_tcp.c @@ -100,13 +100,13 @@ iperf_tcp_send(struct iperf_stream *sp) if (sp->ssl) { if (sp->test->zerocopy) { if (sp->test->diskfile_name != NULL) { - r = Nsendfile_ssl(sp->diskfile_fd, sp->ssl, sp->diskfile_offset, sp->pending_size); + r = Nsendfile_ssl(sp->diskfile_fd, sp->ssl, sp->diskfile_offset, sp->pending_size, SF_NOCACHE); sp->diskfile_offset += r; if (sp->diskfile_offset + sp->settings->blksize >= sp->diskfile_sz) { sp->diskfile_offset = r; } } else { - r = Nsendfile_ssl(sp->buffer_fd, sp->ssl, 0, sp->pending_size); + r = Nsendfile_ssl(sp->buffer_fd, sp->ssl, 0, sp->pending_size, 0); } } else { @@ -116,13 +116,13 @@ iperf_tcp_send(struct iperf_stream *sp) #endif if (sp->test->zerocopy) { if (sp->test->diskfile_name != NULL) { - r = Nsendfile(sp->diskfile_fd, sp->socket, sp->diskfile_offset, sp->pending_size); + r = Nsendfile(sp->diskfile_fd, sp->socket, sp->diskfile_offset, sp->pending_size, SF_NOCACHE); sp->diskfile_offset += r; if (sp->diskfile_offset + sp->settings->blksize >= sp->diskfile_sz) { sp->diskfile_offset = r; } } else { - r = Nsendfile(sp->buffer_fd, sp->socket, 0, sp->pending_size); + r = Nsendfile(sp->buffer_fd, sp->socket, 0, sp->pending_size, 0); } } else { r = Nwrite(sp->socket, sp->buffer, sp->pending_size, Ptcp); diff --git a/src/net.c b/src/net.c index b506dec..63d8e20 100644 --- a/src/net.c +++ b/src/net.c @@ -430,7 +430,7 @@ Nwrite_ssl(SSL * ssl, const char *buf, size_t count, int prot) int -Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count) +Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count, int flags) { #if defined(HAVE_SENDFILE) off_t offset; @@ -440,7 +440,7 @@ Nsendfile_ssl(int fromfd, SSL* tossl, size_t foffset, size_t count) while (nleft > 0) { offset = count - nleft; - r = SSL_sendfile(tossl, fromfd, foffset + offset, nleft, 0); + r = SSL_sendfile(tossl, fromfd, foffset + offset, nleft, flags); if (r < 0) { int err = SSL_get_error(tossl, r); switch (err) { @@ -546,7 +546,7 @@ has_sendfile(void) */ int -Nsendfile(int fromfd, int tofd, size_t foffset, size_t count) +Nsendfile(int fromfd, int tofd, size_t foffset, size_t count, int flags) { off_t offset; #if defined(HAVE_SENDFILE) @@ -564,7 +564,7 @@ Nsendfile(int fromfd, int tofd, size_t foffset, size_t count) if (r > 0) nleft -= r; #elif defined(__FreeBSD__) - r = sendfile(fromfd, tofd, foffset + offset, nleft, NULL, &sent, 0); + r = sendfile(fromfd, tofd, foffset + offset, nleft, NULL, &sent, flags); nleft -= sent; #elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_10_6) /* OS X */ sent = nleft; diff --git a/src/net.h b/src/net.h index 3b131bc..1056354 100644 --- a/src/net.h +++ b/src/net.h @@ -34,14 +34,14 @@ int netannounce(int domain, int proto, const char *local, const char *bind_dev, int Nread(int fd, char *buf, size_t count, int prot); int Nwrite(int fd, const char *buf, size_t count, int prot) /* __attribute__((hot)) */; int has_sendfile(void); -int Nsendfile(int fromfd, int tofd, size_t offset, size_t count) /* __attribute__((hot)) */; +int Nsendfile(int fromfd, int tofd, size_t offset, size_t count, int flags) /* __attribute__((hot)) */; int setnonblocking(int fd, int nonblocking); int getsockdomain(int sock); int parse_qos(const char *tos); int Nread_ssl(SSL* ssl, char *buf, size_t count, int prot); int Nwrite_ssl(SSL * ssl, const char *buf, size_t count, int prot); -int Nsendfile_ssl(int fromfd, SSL* tossl, size_t offset, size_t count); +int Nsendfile_ssl(int fromfd, SSL* tossl, size_t offset, size_t count, int flags); #define NET_SOFTERROR -1 #define NET_HARDERROR -2