Skip to content

Commit

Permalink
Improve Exit Error Handling for failures in PASE pairing requests (#3…
Browse files Browse the repository at this point in the history
…6160)

* Improve Error Handling for failures in PASE pairing requests

* Integrating comments

* clarifying Pair API contract regarding the delegate

* integrating comment on API
  • Loading branch information
Alami-Amine authored Oct 22, 2024
1 parent 9afad66 commit c98b1f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,15 @@ CHIP_ERROR PASESession::Pair(SessionManager & sessionManager, uint32_t peerSetUp
exit:
if (err != CHIP_NO_ERROR)
{
// If a failure happens before we have placed the incoming exchange into `mExchangeCtxt`, we need to make
// sure to close the exchange to fulfill our API contract.
if (!mExchangeCtxt.HasValue())
{
exchangeCtxt->Close();
}
Clear();
ChipLogError(SecureChannel, "Failed during PASE session pairing request: %" CHIP_ERROR_FORMAT, err.Format());
MATTER_TRACE_COUNTER("PASEFail");
}
return err;
}
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/secure_channel/PASESession.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class DLL_EXPORT PASESession : public Messaging::UnsolicitedMessageHandler,
* ownership of the exchangeCtxt to PASESession object. PASESession
* will close the exchange on (successful/failed) handshake completion.
* @param delegate Callback object
* The delegate will be notified if and only if Pair() returns success. Errors occurring after Pair()
* returns success will be reported via the delegate.
*
* @return CHIP_ERROR The result of initialization
*/
Expand Down

0 comments on commit c98b1f5

Please sign in to comment.