iperf icon indicating copy to clipboard operation
iperf copied to clipboard

Stop a test if one of the threads terminated because of an error

Open davidBar-On opened this issue 1 year ago • 0 comments

  • Version of iperf3 (or development branch, such as master or 3.1-STABLE) to which this pull request applies: master

  • Issues fixed (if any): #1696

  • Brief description of code changes (suitable for use as a commit message):

Suggested enhancement to terminate a test when one of the threads fail. Currently, even with one thread that fails, iperf3 continues to run the test (and reports 0 bytes transferred). The issue was detected while evaluating PR #1616. UPDATE: Added a fix for #1696 - try to cancel a stream's thread only if it was created. This can happen if the client terminate before all threads for the streams where created.

The suggest fix approach is that both the client and the server will keep a counter for the number of threads running, which is shared by all threads. If a thread encounters an error, it subtract 1 from this counter before terminating. The client/server main loop is checking whether the counter value equals the expected number of threads.

My initially approach was using pthread_kill(thread, 0) to check whether any of the streams threads terminated. This is a more robust solution, since it also detects termination because of exceptions. However, I thought the overhead of such check is too high. I am not sure whether this is the case, since the check is done in the main thread.

davidBar-On avatar Feb 24 '24 17:02 davidBar-On