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

Commit f60b5246 authored by Zach Johnson's avatar Zach Johnson
Browse files

rusty-gd: some tidying in acl

use short variable names where the usage context is so small it's self
explanatory (a little more go-like)

Bug: 171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost
Change-Id: Iada70c9f33d141e93828c14dcad31057195027bb
parent 9ae2d47a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -139,8 +139,9 @@ async fn provide_acl_manager(
) -> AclManager {
    let (req_tx, mut req_rx) = channel::<Request>(10);
    let (conn_evt_tx, conn_evt_rx) = channel::<Event>(10);
    let local_rt = rt.clone();

    rt.clone().spawn(async move {
    local_rt.spawn(async move {
        let connections: Arc<Mutex<HashMap<u16, ConnectionInternal>>> = Arc::new(Mutex::new(HashMap::new()));
        let mut connect_queue: Vec<Address> = Vec::new();
        let mut pending = PendingConnect::None;
+22 −26
Original line number Diff line number Diff line
@@ -127,47 +127,43 @@ async fn provide_acl_dispatch(
                        },
                    }
                },
                Some(packet) = consume(&acl.rx) => {
                    match connections.get_mut(&packet.get_handle()) {
                        Some(connection) => connection.reassembler.on_packet(packet).await,
                        None if packet.get_handle() == QCOM_DEBUG_HANDLE => {},
                        None => info!("no acl for {}", packet.get_handle()),
                Some(p) = consume(&acl.rx) => {
                    match connections.get_mut(&p.get_handle()) {
                        Some(c) => c.reassembler.on_packet(p).await,
                        None if p.get_handle() == QCOM_DEBUG_HANDLE => {},
                        None => info!("no acl for {}", p.get_handle()),
                    }
                },
                Some(packet) = classic_outbound.next(), if classic_credits > 0 => {
                    acl.tx.send(packet).await.unwrap();
                Some(p) = classic_outbound.next(), if classic_credits > 0 => {
                    acl.tx.send(p).await.unwrap();
                    classic_credits -= 1;
                },
                Some(packet) = le_outbound.next(), if le_credits > 0 => {
                    acl.tx.send(packet).await.unwrap();
                Some(p) = le_outbound.next(), if le_credits > 0 => {
                    acl.tx.send(p).await.unwrap();
                    le_credits -= 1;
                },
                Some(evt) = evt_rx.recv() => {
                    match evt.specialize() {
                        NumberOfCompletedPackets(evt) => {
                            for info in evt.get_completed_packets() {
                                match connections.get(&info.connection_handle) {
                                    Some(connection) => {
                                        let credits = info.host_num_of_completed_packets;
                                        match connection.bt {
                                            Classic => {
                                                classic_credits += credits;
                            for entry in evt.get_completed_packets() {
                                match connections.get(&entry.connection_handle) {
                                    Some(conn) => {
                                        let credits = entry.host_num_of_completed_packets;
                                        match conn.bt {
                                            Classic => classic_credits += credits,
                                            Le => le_credits += credits,
                                        }
                                        assert!(classic_credits <= controller.acl_buffers);
                                            },
                                            Le => {
                                                le_credits += credits;
                                        assert!(le_credits <= controller.le_buffers.into());
                                    },
                                        }
                                    },
                                    None => info!("dropping credits for unknown connection {}", info.connection_handle),
                                    None => info!("dropping credits for unknown connection {}", entry.connection_handle),
                                }
                            }
                        },
                        DisconnectionComplete(evt) => {
                            if let Some(connection) = connections.remove(&evt.get_connection_handle()) {
                                connection.close_tx.send(()).unwrap();
                                connection.evt_tx.send(evt.into()).await.unwrap();
                            if let Some(c) = connections.remove(&evt.get_connection_handle()) {
                                c.close_tx.send(()).unwrap();
                                c.evt_tx.send(evt.into()).await.unwrap();
                            }
                        },
                        _ => unimplemented!(),