STAR-1582 Fix deadlock on client stop #32
Merged
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.
Fix deadlock when shutting down a client, which would get stuck indefinitely 1 out of 5 times in the main thread when calling stop. The deadlock was caused by the main thread getting stuck while waiting for the client thread to join. At the same time, the client worker thread was stuck waiting for recv to return a value. In case no data was sent on the network and the remote side did not disconnect, the main thread would be stuck indefinitely. This commit solves the issue by first closing the SRT socket before trying to join the thread, instead of after, as earlier. This makes the recv call return an error and exit the thread loop.