-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leak in Worker::mapChannelRequestHandlers and other maps #892
Comments
Possible C++ problem here:
Anyway, IMHO the solution is:
|
Makes sense to me, I didn't think about it. Do you have capacity to implement this before I do by any chance? |
I can try tomorrow. BTW reminder for me: include those Worker maps in dump() output so we can test their values in tests. |
Working in #894 |
Bug Report
Your environment
Issue 1 description
By looking at where we call
OnChannelRequestHandlerRemoved()
I'm pretty sure that we are leaking an entry inWorker::mapChannelRequestHandlers
when we close aRouter
via Noderouter.close()
method and such aRouter
containsRtpObservers
.this->listener->OnChannelRequestHandlerRemoved(rtpObserver->id);
is just called inRouter
when receiving aChannel::ChannelRequest::MethodId::ROUTER_CLOSE_RTP_OBSERVER
request. However we do not send that channel request when we close theRouter
directly viarouter.close()
, so here a leak.Regarding other entities (for instance,
Consumer
) we rely onRouter::OnTransportConsumerClosed()
to clean the entry in the map when theConsumer
is closed, but right now I do not remember if such aRouter::OnTransportConsumerClosed
is called in every case. For example, if we calltransport.close()
:OnTransportConsumerClosed()
is called inTransport::CloseProducersAndConsumers()
, so the same: I'm not sure ifTransport::CloseProducersAndConsumers()
is always called when closing theTransport
directly or when closing theRouter
directly`.Some applies to
Producer
andDataXxxxxxxx
classes, and not sure about transports.Issue 2 description
Now a different potential issue. Imagine this scenario:
Producer
or whatever).OnChannelRequestHandlerRemoved(producerId)
so it gets into the map.Producer
creation fail so the code throws.producerId
in the map forever.Proposal that would fix all issues
Entities inherit from
ChannelSocket
and so on. Such a class may implement a constructor and a destructor so the constructor is the only one that callsOnChannelRequestHandlerAdded(this)
and the destructor callsOnChannelRequestHandlerRemoved(this)
. We do something similar somewhere else to register and unregister things. I think this mechanism would be much safer and reliable than current one.The text was updated successfully, but these errors were encountered: