Skip to content

Conversation

@tomasoh-ateliere
Copy link

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.

Fix deadlock when shutting down a client, which would get stuck indefinitly 1 out of 5 times in the main thread when calling stop. The
deadlock was casued 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 will be stuck indefinitly. 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.
@tomasoh-ateliere tomasoh-ateliere requested a review from a team May 20, 2025 08:20
Copy link

@permobergedge permobergedge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

@tomasoh-ateliere tomasoh-ateliere merged commit 06c072f into master May 20, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants