Created
February 8, 2023 02:00
-
-
Save kazuho/2e4a4bc02792bc9c5f622b1a4d43caf2 to your computer and use it in GitHub Desktop.
iperf3 splice patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/iperf_api.c b/src/iperf_api.c | |
index 09ab6af..a54be44 100644 | |
--- a/src/iperf_api.c | |
+++ b/src/iperf_api.c | |
@@ -4520,11 +4520,26 @@ diskfile_recv(struct iperf_stream *sp) | |
{ | |
int r; | |
+#if 1 | |
+ static int pipefds[2] = {-1, -1}; | |
+ if (pipefds[0] == -1) | |
+ pipe(pipefds); | |
+ r = splice(sp->socket, NULL, pipefds[1], NULL, sp->settings->blksize, SPLICE_F_NONBLOCK); | |
+ if (r > 0 && sp->test->state == TEST_RUNNING) { | |
+ splice(pipefds[0], NULL, sp->diskfile_fd, NULL, r, 0); | |
+ sp->result->bytes_received += r; | |
+ sp->result->bytes_received_this_interval += r; | |
+ } | |
+ if (r < 0) { | |
+ perror("Hmmm"); | |
+ } | |
+#else | |
r = sp->rcv2(sp); | |
if (r > 0) { | |
// NOTE: Currently ignoring the return value of writing to disk | |
(void) (write(sp->diskfile_fd, sp->buffer, r) + 1); | |
} | |
+#endif | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment