Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: prevent lockup on connection destruction (#2412)
When we destroy Mavsdk and clear the list of connections, we likely end up in a deadlock. What happens is that: 1. A connection wants to forward a message and is trying to acquire the connection mutex. 2. At the same time, the connection is being destroyed, so we are waiting for the connection receive thread to be joinable. While the connections are being destroyed, we have the connection mutex which is blocking 1. The proposed solution is to: 1. Make it less likely by acquiring the connection mutex properly before checking _connections.size() and not for the individual connections. 2. Check the _should_exit flag before trying to acquire the mutex. I believe by the time the connections are being cleared, this flag is set, and hence the deadlock should not happen, fingers crossed.
- Loading branch information