Stop a test if one of the threads terminated because of an error #1654
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Version of iperf3 (or development branch, such as
master
or3.1-STABLE
) to which this pull request applies:master
Issues fixed (if any): Segfault during
cleanup_server
for bidirectional or with parallel stream tests ended early #1696Brief 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.