Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BACKPORT v2.12] core: prevent lockup on connection destruction #2412

Merged
merged 1 commit into from
Oct 3, 2024

Commits on Oct 3, 2024

  1. core: prevent lockup on connection destruction

    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.
    julianoes committed Oct 3, 2024
    Configuration menu
    Copy the full SHA
    4505533 View commit details
    Browse the repository at this point in the history