Fix issue 1061 - not fail in WSL1 when cannot get default congestion alg name (#1126)

This commit is contained in:
David Bar-On 2021-03-15 21:18:00 +02:00 committed by GitHub
parent de006004d4
commit 53a68308ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -83,14 +83,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);
}

View File

@ -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);
@ -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);
}