WgPeerExtraData now uses OnDestroy so lifetime can be controlled
This commit is contained in:
parent
d04afa1cdb
commit
23b4e819ad
3 changed files with 9 additions and 2 deletions
|
@ -171,6 +171,11 @@ class PluginPeer : public WgPeerExtraData {
|
|||
public:
|
||||
PluginPeer(TunsafePluginImpl *plugin, WgPeer *peer) : plugin(plugin), peer(peer), token_client_handler(this) {}
|
||||
~PluginPeer();
|
||||
|
||||
virtual void OnPeerDestroy() override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
WgPeer *peer;
|
||||
TunsafePluginImpl *plugin;
|
||||
TokenClientHandler token_client_handler;
|
||||
|
|
|
@ -392,7 +392,8 @@ WgPeer::~WgPeer() {
|
|||
assert(curr_keypair_ == NULL && next_keypair_ == NULL && prev_keypair_ == NULL);
|
||||
assert(local_key_id_during_hs_ == 0);
|
||||
assert(first_queued_packet_ == NULL);
|
||||
delete peer_extra_data_;
|
||||
if (peer_extra_data_)
|
||||
peer_extra_data_->OnPeerDestroy();
|
||||
}
|
||||
|
||||
void WgPeer::DelayedDelete(void *x) {
|
||||
|
|
|
@ -468,7 +468,8 @@ private:
|
|||
// Allows associating extradata with peers that can be used by plugins etc.
|
||||
class WgPeerExtraData {
|
||||
public:
|
||||
virtual ~WgPeerExtraData() {}
|
||||
// This is called when the peer is destroyed.
|
||||
virtual void OnPeerDestroy() = 0;
|
||||
};
|
||||
|
||||
// State for peer
|
||||
|
|
Loading…
Reference in a new issue