Skip to content

Commit

Permalink
Fix issue 1061 - not fail in WSL1 when cannot get default congestion …
Browse files Browse the repository at this point in the history
…alg name (esnet#1126)
  • Loading branch information
davidBar-On authored and hanvari committed Jul 3, 2021
1 parent 23ca534 commit 4e2b847
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/iperf_client_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ iperf_create_streams(struct iperf_test *test, int sender)
{
socklen_t len = TCP_CA_NAME_MAX;
char ca[TCP_CA_NAME_MAX + 1];
if (getsockopt(s, IPPROTO_TCP, TCP_CONGESTION, ca, &len) < 0) {
int rc;
rc = getsockopt(s, IPPROTO_TCP, TCP_CONGESTION, ca, &len);
if (rc < 0 && test->congestion) {
saved_errno = errno;
close(s);
errno = saved_errno;
i_errno = IESETCONGESTION;
return -1;
}
test->congestion_used = strdup(ca);
// Set actual used congestion alg, or set to unknown if could not get it
if (rc < 0)
test->congestion_used = strdup("unknown");
else
test->congestion_used = strdup(ca);
if (test->debug) {
printf("Congestion algorithm is %s\n", test->congestion_used);
}
Expand Down
10 changes: 8 additions & 2 deletions src/iperf_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ iperf_run_server(struct iperf_test *test)
{
socklen_t len = TCP_CA_NAME_MAX;
char ca[TCP_CA_NAME_MAX + 1];
if (getsockopt(s, IPPROTO_TCP, TCP_CONGESTION, ca, &len) < 0) {
int rc;
rc = getsockopt(s, IPPROTO_TCP, TCP_CONGESTION, ca, &len);
if (rc < 0 && test->congestion) {
saved_errno = errno;
close(s);
cleanup_server(test);
Expand All @@ -621,7 +623,11 @@ iperf_run_server(struct iperf_test *test)
if (test->congestion_used != NULL) {
free(test->congestion_used);
}
test->congestion_used = strdup(ca);
// Set actual used congestion alg, or set to unknown if could not get it
if (rc < 0)
test->congestion_used = strdup("unknown");
else
test->congestion_used = strdup(ca);
if (test->debug) {
printf("Congestion algorithm is %s\n", test->congestion_used);
}
Expand Down

0 comments on commit 4e2b847

Please sign in to comment.