Skip to content

Commit

Permalink
fix: ensure signal identifier 0 is never used
Browse files Browse the repository at this point in the history
  • Loading branch information
lulf committed Apr 11, 2024
1 parent a3bb133 commit cef3f9e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions host/src/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ impl<'d, M: RawMutex, const CHANNELS: usize, const L2CAP_TXQ: usize, const L2CAP
fn next_request_id(&self) -> u8 {
self.state.lock(|state| {
let mut state = state.borrow_mut();
// 0 is an invalid identifier
if state.next_req_id == 0 {
state.next_req_id = state.next_req_id + 1;
}
let next = state.next_req_id;
state.next_req_id = state.next_req_id.wrapping_add(1);
next
Expand Down Expand Up @@ -277,7 +281,7 @@ impl<'d, M: RawMutex, const CHANNELS: usize, const L2CAP_TXQ: usize, const L2CAP
let mps = req.mps.min(self.pool.mtu() as u16 - 4);
mtu = req.mtu.min(mtu);
let credits = self.pool.min_available(AllocId::dynamic(idx)) as u16;
//info!("Accept, initial credits: {}", credits);
// info!("Accept L2CAP, initial credits: {}", credits);
ConnectedState {
conn: req.conn,
cid: req.cid,
Expand All @@ -304,8 +308,6 @@ impl<'d, M: RawMutex, const CHANNELS: usize, const L2CAP_TXQ: usize, const L2CAP
}),
);

// info!("Responding to create: {:?}", response);

controller.signal(conn, response).await?;

// Send initial credits
Expand Down

0 comments on commit cef3f9e

Please sign in to comment.