Skip to content

Commit

Permalink
Merge branch 'esnet:master' into 64bit-MAX_PACING_RATE
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosfsch authored Jul 23, 2024
2 parents c0983a3 + 922820e commit a40b05a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/iperf_server_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,26 @@ iperf_accept(struct iperf_test *test)
i_errno = IERECVCOOKIE;
goto error_handling;
}
FD_SET(test->ctrl_sck, &test->read_set);
if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck;
FD_SET(test->ctrl_sck, &test->read_set);
if (test->ctrl_sck > test->max_fd) test->max_fd = test->ctrl_sck;

if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0)
goto error_handling;
if (iperf_exchange_parameters(test) < 0)
goto error_handling;
if (test->server_affinity != -1)
if (iperf_setaffinity(test, test->server_affinity) != 0)
if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0)
goto error_handling;
if (iperf_exchange_parameters(test) < 0)
goto error_handling;
if (test->server_affinity != -1) {
if (iperf_setaffinity(test, test->server_affinity) != 0)
goto error_handling;
}
if (test->on_connect)
test->on_connect(test);
} else {
/*
* Don't try to read from the socket. It could block an ongoing test.
* Just send ACCESS_DENIED.
/*
* Don't try to read from the socket. It could block an ongoing test.
* Just send ACCESS_DENIED.
* Also, if sending failed, don't return an error, as the request is not related
* to the ongoing test, and returning an error will terminate the test.
*/
*/
if (Nwrite(s, (char*) &rbuf, sizeof(rbuf), Ptcp) < 0) {
if (test->debug)
printf("failed to send ACCESS_DENIED to an unsolicited connection request during active test\n");
Expand All @@ -220,7 +221,7 @@ iperf_handle_message_server(struct iperf_test *test)
// XXX: Need to rethink how this behaves to fit API
if ((rval = Nread(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp)) <= 0) {
if (rval == 0) {
iperf_err(test, "the client has unexpectedly closed the connection");
iperf_err(test, "the client has unexpectedly closed the connection");
i_errno = IECTRLCLOSE;
test->state = IPERF_DONE;
return 0;
Expand All @@ -234,7 +235,7 @@ iperf_handle_message_server(struct iperf_test *test)
case TEST_START:
break;
case TEST_END:
test->done = 1;
test->done = 1;
cpu_util(test->cpu_util);
test->stats_callback(test);
SLIST_FOREACH(sp, &test->streams, streams) {
Expand All @@ -243,11 +244,11 @@ iperf_handle_message_server(struct iperf_test *test)
close(sp->socket);
}
test->reporter_callback(test);
if (iperf_set_send_state(test, EXCHANGE_RESULTS) != 0)
if (iperf_set_send_state(test, EXCHANGE_RESULTS) != 0)
return -1;
if (iperf_exchange_results(test) < 0)
return -1;
if (iperf_set_send_state(test, DISPLAY_RESULTS) != 0)
if (iperf_set_send_state(test, DISPLAY_RESULTS) != 0)
return -1;
if (test->on_test_finish)
test->on_test_finish(test);
Expand Down Expand Up @@ -513,21 +514,24 @@ iperf_run_server(struct iperf_test *test)
int64_t timeout_us;
int64_t rcv_timeout_us;

if (test->logfile)
if (test->logfile) {
if (iperf_open_logfile(test) < 0)
return -2;
}

if (test->affinity != -1)
if (test->affinity != -1) {
if (iperf_setaffinity(test, test->affinity) != 0) {
cleanup_server(test);
return -2;
}
}

if (test->json_output)
if (test->json_output) {
if (iperf_json_start(test) < 0) {
cleanup_server(test);
return -2;
}
}

if (test->json_output) {
cJSON_AddItemToObject(test->json_start, "version", cJSON_CreateString(version));
Expand Down
1 change: 1 addition & 0 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,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

0 comments on commit a40b05a

Please sign in to comment.