Closed ndfred closed 5 years ago
Interesting article from 2015 on how sendfile is broken on macOS (iOS 9 was released in 2015) https://blog.phusion.nl/2015/06/04/the-brokenness-of-the-sendfile-system-call/
Another somewhat related issue https://github.com/ecdavis/pants/issues/43
Tried to make the mmap
region not be backed by an actual file but that doesn't solve the problem, changeset:
diff --git a/Source/Backend/IPFTestRunner.m b/Source/Backend/IPFTestRunner.m
index 0cb8b90..29bd72f 100644
--- a/Source/Backend/IPFTestRunner.m
+++ b/Source/Backend/IPFTestRunner.m
@@ -88,7 +88,7 @@ - (void)startTest:(IPFTestRunnerCallback)callback
iperf_set_test_num_streams(test, (int)configuration.streams);
iperf_set_test_reverse(test, configuration.reverse);
iperf_set_test_template(test, (char *)[streamFilePathTemplate cStringUsingEncoding:NSUTF8StringEncoding]);
-// iperf_set_test_zerocopy(test, 1);
+ iperf_set_test_zerocopy(test, 1);
i_errno = IENONE;
test->reporter_callback = vc_reporter_callback;
diff --git a/Source/iperf3/iperf_api.c b/Source/iperf3/iperf_api.c
index 8b65d23..9e17936 100755
--- a/Source/iperf3/iperf_api.c
+++ b/Source/iperf3/iperf_api.c
@@ -3321,7 +3321,7 @@ iperf_new_stream(struct iperf_test *test, int s)
free(sp);
return NULL;
}
- sp->buffer = (char *) mmap(NULL, test->settings->blksize, PROT_READ|PROT_WRITE, MAP_PRIVATE, sp->buffer_fd, 0);
+ sp->buffer = (char *) mmap(NULL, test->settings->blksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (sp->buffer == MAP_FAILED) {
i_errno = IECREATESTREAM;
free(sp->result);
sendfile
is just buggy on iOS and doesn't improve performance anyway, let's not use it and close this
Crashing with SIGSYS on
r = sendfile(fromfd, tofd, offset, &sent, NULL, 0);
, do older versions of iOS support sendfile? There may be a way to detect that.