diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 82ae6587bbb816..f9a810a6d0d981 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -134,7 +134,7 @@ CHIP_ERROR SessionManager::PrepareMessage(SessionHandle sessionHandle, PayloadHe { ReturnErrorOnFailure(payloadHeader.EncodeBeforeData(message)); - MessageCounter & counter = sessionHandle.GetUnauthenticatedSession()->GetLocalMessageCounter(); + MessageCounter & counter = mGlobalUnencryptedMessageCounter; uint32_t messageCounter = counter.Value(); ReturnErrorOnFailure(counter.Advance()); diff --git a/src/transport/UnauthenticatedSessionTable.h b/src/transport/UnauthenticatedSessionTable.h index e09cb46d89f773..381a7a4a0d64bc 100644 --- a/src/transport/UnauthenticatedSessionTable.h +++ b/src/transport/UnauthenticatedSessionTable.h @@ -47,7 +47,7 @@ class UnauthenticatedSessionDeleter class UnauthenticatedSession : public ReferenceCounted { public: - UnauthenticatedSession(const PeerAddress & address) : mPeerAddress(address) { mLocalMessageCounter.Init(); } + UnauthenticatedSession(const PeerAddress & address) : mPeerAddress(address) {} UnauthenticatedSession(const UnauthenticatedSession &) = delete; UnauthenticatedSession & operator=(const UnauthenticatedSession &) = delete; @@ -59,14 +59,12 @@ class UnauthenticatedSession : public ReferenceCounted