Fix Service object leak on emulation stop

Services created with the ServiceFramework base class install themselves as HleHandlers with an owning shared_ptr in the ServerPort ServiceFrameworkBase::port member variable, creating a cyclic ownership between ServiceFrameworkBase and the ServerPort, preventing deletion of the service objects.

Fix that by removing the ServiceFrameworkBase::port member because that was only used to detect multiple attempts at installing a port. Instead store a flag if the port was already installed to achieve the same functionality.
This commit is contained in:
Jens Schmer 2018-12-12 20:07:14 +01:00
parent 700075beb6
commit 27a9cc2e63
2 changed files with 12 additions and 10 deletions

View file

@ -96,11 +96,9 @@ private:
/// Maximum number of concurrent sessions that this service can handle.
u32 max_sessions;
/**
* Port where incoming connections will be received. Only created when InstallAsService() or
* InstallAsNamedPort() are called.
*/
Kernel::SharedPtr<Kernel::ServerPort> port;
/// Flag to store if a port was already create/installed to detect multiple install attempts,
/// which is not supported.
bool port_installed = false;
/// Function used to safely up-cast pointers to the derived class before invoking a handler.
InvokerFn* handler_invoker;