diff --git a/PropertySheet.props b/PropertySheet.props index b8e21b5..1d4fed5 100644 --- a/PropertySheet.props +++ b/PropertySheet.props @@ -4,7 +4,7 @@ 2 7 - 0 + 1 diff --git a/trie.cpp b/trie.cpp index 4a6bd8c..c50e9eb 100644 --- a/trie.cpp +++ b/trie.cpp @@ -138,6 +138,8 @@ IPTrie::Insert(const UCHAR* ip, int prefixLength, OvpnPeerContext* peer) { } // update the node with the peer info + // keep track of any existing peer so we can release it outside the lock + OvpnPeerContext* oldPeer = current->peer; current->peer = peer; current->isRoute = true; @@ -148,6 +150,12 @@ IPTrie::Insert(const UCHAR* ip, int prefixLength, OvpnPeerContext* peer) { ExReleaseSpinLockExclusive(&Lock, kirql); + // release the previous peer outside the lock if it existed + if (oldPeer) { + LOG_INFO("Release previous peer", TraceLoggingValue(oldPeer->PeerId, "peerId")); + OvpnPeerCtxRelease(oldPeer); + } + done: LOG_EXIT(); return status;