Skip to content

Commit c98b1f5

Browse files
authoredOct 22, 2024
Improve Exit Error Handling for failures in PASE pairing requests (project-chip#36160)
* Improve Error Handling for failures in PASE pairing requests * Integrating comments * clarifying Pair API contract regarding the delegate * integrating comment on API
1 parent 9afad66 commit c98b1f5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎src/protocols/secure_channel/PASESession.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,15 @@ CHIP_ERROR PASESession::Pair(SessionManager & sessionManager, uint32_t peerSetUp
232232
exit:
233233
if (err != CHIP_NO_ERROR)
234234
{
235+
// If a failure happens before we have placed the incoming exchange into `mExchangeCtxt`, we need to make
236+
// sure to close the exchange to fulfill our API contract.
237+
if (!mExchangeCtxt.HasValue())
238+
{
239+
exchangeCtxt->Close();
240+
}
235241
Clear();
242+
ChipLogError(SecureChannel, "Failed during PASE session pairing request: %" CHIP_ERROR_FORMAT, err.Format());
243+
MATTER_TRACE_COUNTER("PASEFail");
236244
}
237245
return err;
238246
}

‎src/protocols/secure_channel/PASESession.h

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ class DLL_EXPORT PASESession : public Messaging::UnsolicitedMessageHandler,
9999
* ownership of the exchangeCtxt to PASESession object. PASESession
100100
* will close the exchange on (successful/failed) handshake completion.
101101
* @param delegate Callback object
102+
* The delegate will be notified if and only if Pair() returns success. Errors occurring after Pair()
103+
* returns success will be reported via the delegate.
102104
*
103105
* @return CHIP_ERROR The result of initialization
104106
*/

0 commit comments

Comments
 (0)
Please sign in to comment.