iperf: prevent client infinite loop
authorEunBong Song <eunb.song@samsung.com>
Mon, 7 Aug 2017 02:05:23 +0000 (19:05 -0700)
committerEunBong Song <eunb.song@samsung.com>
Wed, 30 Aug 2017 04:15:49 +0000 (21:15 -0700)
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 <eunb.song@samsung.com>
apps/examples/iperf/iperf_client_api.c

index 4cfaddf..83621f2 100644 (file)
@@ -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);
+                               }
                }
        }