From 24a351371fa4dbd78614788014ef56eb775a45a0 Mon Sep 17 00:00:00 2001 From: Zang MingJie Date: Wed, 12 Jan 2022 05:44:03 +0800 Subject: [PATCH] Close exchange when session is released (#13448) * Close exchange when session is released * Add clearRetransTable parameter to DoClose call Co-authored-by: Andrei Litvin --- src/messaging/ExchangeContext.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/messaging/ExchangeContext.cpp b/src/messaging/ExchangeContext.cpp index 3a5cfb477ee7c7..8ec3b67989aff8 100644 --- a/src/messaging/ExchangeContext.cpp +++ b/src/messaging/ExchangeContext.cpp @@ -317,17 +317,18 @@ bool ExchangeContext::MatchExchange(const SessionHandle & session, const PacketH void ExchangeContext::OnSessionReleased() { - if (!IsResponseExpected()) + ExchangeHandle ref(*this); + + if (IsResponseExpected()) { - // Nothing to do in this case - return; + // If we're waiting on a response, we now know it's never going to show up + // and we should notify our delegate accordingly. + CancelResponseTimer(); + SetResponseExpected(false); + NotifyResponseTimeout(); } - // If we're waiting on a response, we now know it's never going to show up - // and we should notify our delegate accordingly. - CancelResponseTimer(); - SetResponseExpected(false); - NotifyResponseTimeout(); + DoClose(true /* clearRetransTable */); } CHIP_ERROR ExchangeContext::StartResponseTimer()