Skip to content

Commit 1791390

Browse files
committed
Revert "Use RAII for group session iteration (project-chip#32970) (project-chip#33122)"
This reverts commit 29ed2f9. Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
1 parent b9902ab commit 1791390

File tree

1 file changed

+4
-31
lines changed

1 file changed

+4
-31
lines changed

src/transport/SessionManager.cpp

+4-31
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,6 @@ using Transport::SecureSession;
5858
namespace {
5959
Global<GroupPeerTable> gGroupPeerTable;
6060

61-
/// RAII class for iterators that guarantees that Release() will be called
62-
/// on the underlying type
63-
template <typename Releasable>
64-
class AutoRelease
65-
{
66-
public:
67-
AutoRelease(Releasable * iter) : mIter(iter) {}
68-
~AutoRelease() { Release(); }
69-
70-
Releasable * operator->() { return mIter; }
71-
const Releasable * operator->() const { return mIter; }
72-
73-
bool IsNull() const { return mIter == nullptr; }
74-
75-
void Release()
76-
{
77-
VerifyOrReturn(mIter != nullptr);
78-
mIter->Release();
79-
mIter = nullptr;
80-
}
81-
82-
private:
83-
Releasable * mIter = nullptr;
84-
};
85-
8661
// Helper function that strips off the interface ID from a peer address that is
8762
// not an IPv6 link-local address. For any other address type we should rely on
8863
// the device's routing table to route messages sent. Forcing messages down a
@@ -908,11 +883,8 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & partialPack
908883

909884
// Trial decryption with GroupDataProvider
910885
Credentials::GroupDataProvider::GroupSession groupContext;
911-
912-
AutoRelease<Credentials::GroupDataProvider::GroupSessionIterator> iter(
913-
groups->IterateGroupSessions(partialPacketHeader.GetSessionId()));
914-
915-
if (iter.IsNull())
886+
auto iter = groups->IterateGroupSessions(partialPacketHeader.GetSessionId());
887+
if (iter == nullptr)
916888
{
917889
ChipLogError(Inet, "Failed to retrieve Groups iterator. Discarding everything");
918890
return;
@@ -959,7 +931,7 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & partialPack
959931
}
960932
#endif // CHIP_CONFIG_PRIVACY_ACCEPT_NONSPEC_SVE2
961933
}
962-
iter.Release();
934+
iter->Release();
963935

964936
if (!decrypted)
965937
{
@@ -997,6 +969,7 @@ void SessionManager::SecureGroupMessageDispatch(const PacketHeader & partialPack
997969
gGroupPeerTable->FindOrAddPeer(groupContext.fabric_index, packetHeaderCopy.GetSourceNodeId().Value(),
998970
packetHeaderCopy.IsSecureSessionControlMsg(), counter))
999971
{
972+
1000973
if (Credentials::GroupDataProvider::SecurityPolicy::kTrustFirst == groupContext.security_policy)
1001974
{
1002975
err = counter->VerifyOrTrustFirstGroup(packetHeaderCopy.GetMessageCounter());

0 commit comments

Comments
 (0)