This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit e3045704190a004958142c12ab0fab5516356081 Author: yintao <[email protected]> AuthorDate: Tue May 13 19:35:20 2025 +0800 netutils/iperf: Ensure the completeness of iperf report Iperf thread may exit first and cannot print average results 288.08- 291.08 sec 30834688 Bytes 82.20 Mbits/sec 291.08- 294.09 sec 30654464 Bytes 81.73 Mbits/sec 294.09- 297.09 sec 30392320 Bytes 81.01 Mbits/sec tcp client send error, error code: 104, reason: Unknown error 104 iperf exit Signed-off-by: yintao <[email protected]> Assisted-by: Kiro:claude-opus-4 --- netutils/iperf/iperf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c index 8f027f1a7..dc36b010c 100644 --- a/netutils/iperf/iperf.c +++ b/netutils/iperf/iperf.c @@ -68,6 +68,7 @@ struct iperf_ctrl_t { FAR struct iperf_ctrl_t *flink; struct iperf_cfg_t cfg; + pthread_t report_thread; bool finish; uintmax_t total_len; uint32_t buffer_len; @@ -395,8 +396,7 @@ static int iperf_start_report(FAR struct iperf_ctrl_t *ctrl) return -1; } - pthread_detach(thread); - + ctrl->report_thread = thread; return 0; } @@ -612,6 +612,7 @@ static int iperf_tcp_server(FAR struct iperf_ctrl_t *ctrl, } ctrl->finish = true; + pthread_join(ctrl->report_thread, NULL); close(listen_socket); return 0; @@ -695,6 +696,7 @@ static int iperf_udp_server(FAR struct iperf_ctrl_t *ctrl, } ctrl->finish = true; + pthread_join(ctrl->report_thread, NULL); close(sockfd); return 0; @@ -789,6 +791,7 @@ static int iperf_udp_client(FAR struct iperf_ctrl_t *ctrl, } ctrl->finish = true; + pthread_join(ctrl->report_thread, NULL); close(sockfd); return 0; @@ -855,6 +858,7 @@ static int iperf_tcp_client(FAR struct iperf_ctrl_t *ctrl, } ctrl->finish = true; + pthread_join(ctrl->report_thread, NULL); close(sockfd); return 0;
