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

Commit 328bf78f authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: btclient: Prevent deadlock in telephony enable

Bug: 287379737
Tag: #floss
Test: manually verified no deadlock on telephony enable
Change-Id: Ib4c2e875026fa9ba4cdcd9733da9d100e23c2b38
parent e954cc27
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -292,7 +292,14 @@ impl IBluetoothCallback for BtCallback {
    fn on_sdp_record_created(&mut self, record: BtSdpRecord, handle: i32) {
        print_info!("SDP record handle={} created", handle);
        if let BtSdpRecord::Mps(_) = record {
            self.context.lock().unwrap().mps_sdp_handle = Some(handle);
            let context = self.context.clone();
            // Callbacks first lock the DBus resource and then lock the context,
            // while the command handlers lock them in the reversed order.
            // `telephony enable` command happens to deadlock easily,
            // so use async call to prevent deadlock here.
            tokio::spawn(async move {
                context.lock().unwrap().mps_sdp_handle = Some(handle);
            });
        }
    }
}