Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark a session defunct if an attempt to send a message on it fails outright. #26778

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp
return CHIP_ERROR_MISSING_SECURE_SESSION;
}

SessionHandle session = GetSessionHandle();
CHIP_ERROR err;

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
Expand All @@ -213,17 +214,29 @@ CHIP_ERROR ExchangeContext::SendMessage(Protocols::Id protocolId, uint8_t msgTyp
else
{
#endif
err = mDispatch.SendMessage(GetExchangeMgr()->GetSessionManager(), mSession.Get().Value(), mExchangeId, IsInitiator(),
err = mDispatch.SendMessage(GetExchangeMgr()->GetSessionManager(), session, mExchangeId, IsInitiator(),
GetReliableMessageContext(), reliableTransmissionRequested, protocolId, msgType,
std::move(msgBuf));
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
}
#endif
// We should only cancel the response timer if the ExchangeContext fails to send the message that starts the response timer.
if (err != CHIP_NO_ERROR && startedResponseTimer)
if (err != CHIP_NO_ERROR)
{
CancelResponseTimer();
SetResponseExpected(false);
// We should only cancel the response timer if the ExchangeContext fails to send the message that starts the response
// timer.
if (startedResponseTimer)
{
CancelResponseTimer();
SetResponseExpected(false);
}

// If we can't even send a message (send failed with a non-transient
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved
// error), mark the session as defunct, just like we would if we
// thought we sent the message and never got a response.
if (session->IsSecureSession() && session->AsSecureSession()->IsCASESession())
{
session->AsSecureSession()->MarkAsDefunct();
tcarmelveilleux marked this conversation as resolved.
Show resolved Hide resolved
}
}

// Standalone acks are not application-level message sends.
Expand Down