You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have expected m_subscriptions to have been cleaned up by the time I get the closed_future.
Not sure if this could be a more serious issue (can the session be reopened and have old sessions? could it be considered a memory leak?). But for me it's an issue because my on_event_fn (indirectly) contains a reference to my wamp_session shared_ptr. So if I don't make sure to UNSUBSCRIBE all the subscriptions before closing the wamp_session the std::shared_ptr<wamp_session> reference counter never reaches zero and wamp_session is never destroyed.
Edit: Actually AFAICS the subscription in only removed from m_subscriptions in process_inbound_unsubscribed(). So I depend on my peer behaving and sending me the reply. If the connection dies for some reason and I can't get the UNSUBSCRIBED message back I'm out of luck.
The text was updated successfully, but these errors were encountered:
Hi ... how about storing a weak_ptr inside your on_event_fn instead of the shared_ptr. The problem is the underlying connection can terminate uncleanly at any point (eg network disconnect), and I'm not sure it would make sense to invoke the on_event_fn to indicate an UNSUBSCRIBED has been received.
Or maybe, the library could be altered to release all internal state upon internal closure (e.g., I think this could be done in wampcc::transition_to_closed, although there might be synchronisation considerations to bare in mind, e.g., what locks need to be taken etc).
But, back to my initial thought. I think it's wrong to use a shared_pointer as you are doing. Shared pointers convey resource ownership semantics, and so by the wamp session holding a reference to itself, it kinds of means it controls its own lifetime! So I think weak pointer will work, you just need to promote it to shared pointer during each callback (infact, a raw pointer would work also).
I would have expected m_subscriptions to have been cleaned up by the time I get the closed_future.
Not sure if this could be a more serious issue (can the session be reopened and have old sessions? could it be considered a memory leak?). But for me it's an issue because my
on_event_fn
(indirectly) contains a reference to my wamp_session shared_ptr. So if I don't make sure to UNSUBSCRIBE all the subscriptions before closing the wamp_session the std::shared_ptr<wamp_session> reference counter never reaches zero and wamp_session is never destroyed.Edit: Actually AFAICS the subscription in only removed from m_subscriptions in process_inbound_unsubscribed(). So I depend on my peer behaving and sending me the reply. If the connection dies for some reason and I can't get the UNSUBSCRIBED message back I'm out of luck.
The text was updated successfully, but these errors were encountered: