apps iperf: Fix abort when iperf_connect fails
authorEunBong Song <eunb.song@samsung.com>
Mon, 24 Jul 2017 10:57:29 +0000 (03:57 -0700)
committerEunBong Song <eunb.song@samsung.com>
Wed, 30 Aug 2017 04:15:46 +0000 (21:15 -0700)
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 <eunb.song@samsung.com>
apps/examples/iperf/iperf_client_api.c

index 407567c..4cfaddf 100644 (file)
@@ -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 */