apps iperf: Fix abort when iperf_connect fails
if iperf_connect fails, it crashes in test->reporter_callback functions.
This patch fixes this problem.
And current iperf_client_end() try to send state after close ctrl socket.
This problem is also fixed by this patch.
@@ -342,19 +342,17 @@ int iperf_client_end(struct iperf_test *test)
{
struct iperf_stream *sp;
+ /* show final summary */
+ test->reporter_callback(test);
+
+ iperf_set_send_state(test, IPERF_DONE);
+
/* Close all stream sockets */
SLIST_FOREACH(sp, &test->streams, streams) {
close(sp->socket);
close(test->ctrl_sck);
}
- /* show final summary */
- test->reporter_callback(test);
-
- if (iperf_set_send_state(test, IPERF_DONE) != 0) {
- return -1;
- }
-
return 0;
}
@@ -390,7 +388,8 @@ int iperf_run_client(struct iperf_test *test)
/* Start the client and connect to the server */
if (iperf_connect(test) < 0) {
- return -1;
+ iperf_free_test(test);
+ exit(1);
}
/* Begin calculating CPU utilization */
