renove data sockets closing from server_timer_proc as it caused threa… #1990
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
masteror3.1-STABLE) to which this pull request applies:master
Issues fixed (if any): none
Brief description of code changes (suitable for use as a commit message):
While evaluation Issue #1986 and simulating disconnect between the client and server, the server crashed after the call to
server_timer_proc(). Using gdb I found that the problem was that thesp->testaddress in the data thread was garbled. I believe that this was because of race condition between the main and data threads:server_timer_proc()closed the data stream and freed thespbuffers.spbuffer was used for something else, garbling thetestaddress` (if this step happens later, depending on the threads race conditions, the crash will not happen).read()/recv()returned 0 - end of file.iperf_tcp_recv()in the data thread performs theif (sp->test->state == TEST_RUNNING)test that cause the server crash because thesp->testis garbled.The suggested fix is that
server_timer_proc()will only close the control socket, but not the data streams. This causes theselect()to fail and then the threads/sockets are closed in the usual way after failure.Another approach was that
server_timer_proc()will close the threads before closing the streams, but I think just closing the control channel is better.Also, I noted that
server_timer_proc()does not issue any error message. I didn't add such message as I am not sure if this is not intentional.