From: EunBong Song Date: Mon, 24 Jul 2017 10:57:29 +0000 (-0700) Subject: apps iperf: Fix abort when iperf_connect fails X-Git-Tag: 1.1_Public_Release~318^2~45 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13ae3a50f715b2d79d85bf40b8d2ab827e3cd44f;p=rtos%2Ftinyara.git 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. Change-Id: I965e3e2b40f1e7e19d913342888c6fc43fa12675 Signed-off-by: EunBong Song --- diff --git a/apps/examples/iperf/iperf_client_api.c b/apps/examples/iperf/iperf_client_api.c index 407567c..4cfaddf 100644 --- a/apps/examples/iperf/iperf_client_api.c +++ b/apps/examples/iperf/iperf_client_api.c @@ -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 */