Skip to content

Commit

Permalink
Changes per reviewer comments and cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Jun 11, 2024
1 parent 787e6ed commit 95ee7db
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
i_errno = IENOSENDFILE;
return -1;
}
test->zerocopy = 1;
test->zerocopy = ZEROCOPY_TCP_SENDFILE;
#endif /* HAVE_MSG_ZEROCOPY */
client_flag = 1;
break;
Expand Down Expand Up @@ -1767,13 +1767,21 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
}

#if defined(HAVE_MSG_ZEROCOPY)
// sero copy for TCP use sendfile()
// UDP supports "zero copy" only using MSG_ZEROCOPY
if (test->protocol->id == Pudp && test->zerocopy)
test->zerocopy = ZEROCOPY_TCP_MSG_ZEROCOPY;
// Zero copy for TCP use sendfile()
if (test->zerocopy && test->protocol->id != Pudp && !has_sendfile()) {
i_errno = IENOSENDFILE;
return -1;
}
// Using MSG_ZEROCOPY is not supported when disk file is used
if (test->diskfile_name != (char*) 0 && test->zerocopy == ZEROCOPY_TCP_MSG_ZEROCOPY) {
i_errno = IEDISKFILEZEROCOPY;
return -1;
}
#else
// sero copy is supported only by TCP
// Zero copy is supported only by TCP
if (test->zerocopy && test->protocol->id != Ptcp) {
i_errno = IENOSENDFILE;
return -1;
Expand Down
1 change: 1 addition & 0 deletions src/iperf_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ enum {
IESNDTIMEOUT = 33, // Illegal message send timeout
IEUDPFILETRANSFER = 34, // Cannot transfer file using UDP
IESERVERAUTHUSERS = 35, // Cannot access authorized users file
IEDISKFILEZEROCOPY = 36, // Sending disk file using MSG_ZEROCOPY is not supported
/* Test errors */
IENEWTEST = 100, // Unable to create a new test (check perror)
IEINITTEST = 101, // Test initialization failed (check perror)
Expand Down
3 changes: 3 additions & 0 deletions src/iperf_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ iperf_strerror(int int_errno)
snprintf(errstr, len, "this OS does not support sendfile");
#endif /* HAVE_MSG_ZEROCOPY */
break;
case IEDISKFILEZEROCOPY:
snprintf(errstr, len, "Sending disk file using MSG_ZEROCOPY is not supported");
break;
case IEOMIT:
snprintf(errstr, len, "bogus value for --omit");
break;
Expand Down
1 change: 1 addition & 0 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ iperf_udp_accept(struct iperf_test *test)
/*
* Create a new "listening" socket to replace the one we were using before.
*/
FD_CLR(test->prot_listener, &test->read_set); // No control messages from old listener
test->prot_listener = netannounce(test->settings->domain, Pudp, test->bind_address, test->bind_dev, test->server_port);
if (test->prot_listener < 0) {
i_errno = IESTREAMLISTEN;
Expand Down
2 changes: 1 addition & 1 deletion src/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ Nrecv(int fd, char *buf, size_t count, int prot, int sock_opt)

while (nleft > 0) {
if (sock_opt)
r = recv(fd, buf, nleft, MSG_TRUNC);
r = recv(fd, buf, nleft, sock_opt);
else
r = read(fd, buf, nleft);

Expand Down

0 comments on commit 95ee7db

Please sign in to comment.