diff --git a/src/iperf_client_api.c b/src/iperf_client_api.c index 23ca67f61..a5860fe53 100644 --- a/src/iperf_client_api.c +++ b/src/iperf_client_api.c @@ -93,6 +93,11 @@ iperf_client_worker_run(void *s) { return NULL; cleanup_and_fail: + if (test->ctrl_sck != -1) { // Make sure test was not cleared yet by the main thread + // Error message is printed to NULL test to prevent adding JSON output context into the thread context + iperf_err(NULL, "Server Worker Thread failed - %s", iperf_strerror(i_errno)); + if (test->ctrl_sck != -1) iflush(test); + } return NULL; } diff --git a/src/iperf_server_api.c b/src/iperf_server_api.c index 66401fa6b..3637600cd 100644 --- a/src/iperf_server_api.c +++ b/src/iperf_server_api.c @@ -106,6 +106,11 @@ iperf_server_worker_run(void *s) { return NULL; cleanup_and_fail: + if (test->ctrl_sck != -1) { // Make sure test was not cleared yet by the main thread + // Error message is printed to NULL test to prevent adding JSON output context into the thread context + iperf_err(NULL, "Server Worker Thread failed - %s", iperf_strerror(i_errno)); + if (test->ctrl_sck != -1) iflush(test); + } return NULL; }