Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba3eea1e authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "rust/gatt: Suppress rust panics on LE disconnection events received...

Merge "rust/gatt: Suppress rust panics on LE disconnection events received after rust module unloading" into main
parents 78ad277d e8d86283
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ pub fn with_arbiter<T>(f: impl FnOnce(&mut IsolationManager) -> T) -> T {
    f(ARBITER.read().unwrap().as_ref().expect("Rust stack is not started").lock().as_mut().unwrap())
}

/// Check if the Arbiter is initialized.
pub fn has_arbiter() -> bool {
    ARBITER.read().unwrap().is_some()
}

/// Test to see if a buffer contains a valid ATT packet with an opcode we
/// are interested in intercepting (those intended for servers that are isolated)
fn try_parse_att_server_packet(
@@ -89,6 +94,13 @@ fn on_le_connect(tcb_idx: u8, advertiser: u8) {
}

fn on_le_disconnect(tcb_idx: u8) {
    // Disconnection events may be received after a FactoryReset
    // is initiated for Bluetooth and the rust arbiter is taken
    // down.
    if !has_arbiter() {
        return;
    }

    let tcb_idx = TransportIndex(tcb_idx);
    let was_isolated = with_arbiter(|arbiter| arbiter.is_connection_isolated(tcb_idx));
    if was_isolated {