mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
SessionIDType::find_weak: added conflict parameter
Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
parent
089aec00b1
commit
0e61a2afd7
@ -166,13 +166,15 @@ namespace openvpn {
|
||||
}
|
||||
|
||||
// Find an element in an unordered map (keyed by Session ID)
|
||||
// using weak equality.
|
||||
// using weak equality. If conflict is true, only return
|
||||
// element that is present by weak equality, but which is
|
||||
// not equal to *this by strong equality.
|
||||
template <typename UNORDERED_MAP>
|
||||
const SessionIDType* find_weak(const UNORDERED_MAP& m) const
|
||||
const SessionIDType* find_weak(const UNORDERED_MAP& m, const bool conflict) const
|
||||
{
|
||||
const size_t bi = m.bucket(*this);
|
||||
for (auto i = m.cbegin(bi); i != m.cend(bi); ++i)
|
||||
if (shortform() == i->first.shortform())
|
||||
if (shortform() == i->first.shortform() && (!conflict || *this != i->first))
|
||||
return &i->first;
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user