Skip to content

Commit

Permalink
Un-reserve the new session immediately (project-chip#180)
Browse files Browse the repository at this point in the history
* Un-reserve the new session immediately

* Address review feedback
  • Loading branch information
ivmarkov authored Jun 6, 2024
1 parent 7e828e4 commit e82599c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions rs-matter/src/secure_channel/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ impl Case {
Some(&session_keys[32..48]),
)?;

// Complete the reserved session and thus make the `Session` instance
// immediately available for use by the system.
//
// We need to do this _before_ we send the response to the peer, or else we risk missing
// (dropping) the first messages the peer would send us on the newly-established session,
// as it might start using it right after it receives the response, while it is still marked
// as reserved.
session.complete();

SCStatusCodes::SessionEstablishmentSuccess
Expand Down
8 changes: 8 additions & 0 deletions rs-matter/src/secure_channel/pake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,14 @@ impl Pake {
.pase_mgr
.borrow_mut()
.disable_pase_session(mdns)?;

// Complete the reserved session and thus make the `Session` instance
// immediately available for use by the system.
//
// We need to do this _before_ we send the response to the peer, or else we risk missing
// (dropping) the first messages the peer would send us on the newly-established session,
// as it might start using it right after it receives the response, while it is still marked
// as reserved.
session.complete();

SCStatusCodes::SessionEstablishmentSuccess
Expand Down
2 changes: 1 addition & 1 deletion rs-matter/src/transport/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ impl<'a> ReservedSession<'a> {
Ok(())
}

pub fn complete(&mut self) {
pub fn complete(mut self) {
self.complete = true;
}
}
Expand Down

0 comments on commit e82599c

Please sign in to comment.