From: EunBong Song Date: Mon, 7 Aug 2017 02:05:23 +0000 (-0700) Subject: iperf: prevent client infinite loop X-Git-Tag: 1.1_Public_Release~318^2~22 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=afe69c4572a6947be305f27246f016dd39acf3f5;p=rtos%2Ftinyara.git iperf: prevent client infinite loop Sometimes iperf client's write_set fds are never cleared and this can cause infinite loop. This situation can happen when write_set is not cleared but test's state is not running because clear write_set is only done in running state. This patch adds clear write_set fds if test state is TEST_END and th ere is not cleared write_fds and this can prevent infinite loop. Change-Id: I3329fc1fa2454793ab2dfcd16eab177294fe3a31 Signed-off-by: EunBong Song --- diff --git a/apps/examples/iperf/iperf_client_api.c b/apps/examples/iperf/iperf_client_api.c index 4cfaddf..83621f2 100644 --- a/apps/examples/iperf/iperf_client_api.c +++ b/apps/examples/iperf/iperf_client_api.c @@ -473,6 +473,12 @@ int iperf_run_client(struct iperf_test *test) if (iperf_recv(test, &read_set) < 0) { return -1; } + } else if (test->state == TEST_END) { + //clear write_set for preventing infinite loop + SLIST_FOREACH(sp, &test->streams, streams) + if (FD_ISSET(sp->socket, &test->write_set)) { + FD_CLR(sp->socket, &test->write_set); + } } }