yuzu-emu
/
yuzu
Archived
1
0
Fork 0

kernel: fix port tracking

This commit is contained in:
Liam 2022-10-30 19:20:55 -04:00
parent 7aa91c8d9c
commit 2228383322
5 changed files with 4 additions and 49 deletions

View File

@ -19,8 +19,6 @@ void KServerPort::Initialize(KPort* parent_port_, std::string&& name_) {
// Set member variables. // Set member variables.
parent = parent_port_; parent = parent_port_;
name = std::move(name_); name = std::move(name_);
kernel.RegisterServerObject(this);
} }
bool KServerPort::IsLight() const { bool KServerPort::IsLight() const {
@ -63,9 +61,6 @@ void KServerPort::Destroy() {
// Close our reference to our parent. // Close our reference to our parent.
parent->Close(); parent->Close();
// Ensure that the global list tracking server objects does not hold on to a reference.
kernel.UnregisterServerObject(this);
} }
bool KServerPort::IsSignaled() const { bool KServerPort::IsSignaled() const {

View File

@ -185,17 +185,6 @@ struct KernelCore::Impl {
} }
void CloseServices() { void CloseServices() {
// Close all open server sessions and ports.
std::unordered_set<KAutoObject*> server_objects_;
{
std::scoped_lock lk(server_objects_lock);
server_objects_ = server_objects;
server_objects.clear();
}
for (auto* server_object : server_objects_) {
server_object->Close();
}
// Ensures all service threads gracefully shutdown. // Ensures all service threads gracefully shutdown.
ClearServiceThreads(); ClearServiceThreads();
} }
@ -699,9 +688,7 @@ struct KernelCore::Impl {
return {}; return {};
} }
KClientPort* port = &search->second(system.ServiceManager(), system); return &search->second(system.ServiceManager(), system);
RegisterServerObject(&port->GetParent()->GetServerPort());
return port;
} }
void RegisterNamedServiceHandler(std::string name, KServerPort* server_port) { void RegisterNamedServiceHandler(std::string name, KServerPort* server_port) {
@ -713,16 +700,6 @@ struct KernelCore::Impl {
search->second(system.ServiceManager(), server_port); search->second(system.ServiceManager(), server_port);
} }
void RegisterServerObject(KAutoObject* server_object) {
std::scoped_lock lk(server_objects_lock);
server_objects.insert(server_object);
}
void UnregisterServerObject(KAutoObject* server_object) {
std::scoped_lock lk(server_objects_lock);
server_objects.erase(server_object);
}
std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(KernelCore& kernel, std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(KernelCore& kernel,
const std::string& name) { const std::string& name) {
auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, name); auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, name);
@ -755,7 +732,6 @@ struct KernelCore::Impl {
service_thread_barrier.Sync(); service_thread_barrier.Sync();
} }
std::mutex server_objects_lock;
std::mutex registered_objects_lock; std::mutex registered_objects_lock;
std::mutex registered_in_use_objects_lock; std::mutex registered_in_use_objects_lock;
@ -786,7 +762,6 @@ struct KernelCore::Impl {
std::unordered_map<std::string, ServiceInterfaceFactory> service_interface_factory; std::unordered_map<std::string, ServiceInterfaceFactory> service_interface_factory;
std::unordered_map<std::string, ServiceInterfaceHandlerFn> service_interface_handlers; std::unordered_map<std::string, ServiceInterfaceHandlerFn> service_interface_handlers;
NamedPortTable named_ports; NamedPortTable named_ports;
std::unordered_set<KAutoObject*> server_objects;
std::unordered_set<KAutoObject*> registered_objects; std::unordered_set<KAutoObject*> registered_objects;
std::unordered_set<KAutoObject*> registered_in_use_objects; std::unordered_set<KAutoObject*> registered_in_use_objects;
@ -1005,14 +980,6 @@ void KernelCore::RegisterNamedServiceHandler(std::string name, KServerPort* serv
impl->RegisterNamedServiceHandler(std::move(name), server_port); impl->RegisterNamedServiceHandler(std::move(name), server_port);
} }
void KernelCore::RegisterServerObject(KAutoObject* server_object) {
impl->RegisterServerObject(server_object);
}
void KernelCore::UnregisterServerObject(KAutoObject* server_object) {
impl->UnregisterServerObject(server_object);
}
void KernelCore::RegisterKernelObject(KAutoObject* object) { void KernelCore::RegisterKernelObject(KAutoObject* object) {
std::scoped_lock lk{impl->registered_objects_lock}; std::scoped_lock lk{impl->registered_objects_lock};
impl->registered_objects.insert(object); impl->registered_objects.insert(object);

View File

@ -204,14 +204,6 @@ public:
/// Accepts a session on a port created by CreateNamedServicePort. /// Accepts a session on a port created by CreateNamedServicePort.
void RegisterNamedServiceHandler(std::string name, KServerPort* server_port); void RegisterNamedServiceHandler(std::string name, KServerPort* server_port);
/// Registers a server session or port with the gobal emulation state, to be freed on shutdown.
/// This is necessary because we do not emulate processes for HLE sessions and ports.
void RegisterServerObject(KAutoObject* server_object);
/// Unregisters a server session or port previously registered with RegisterServerSession when
/// it was destroyed during the current emulation session.
void UnregisterServerObject(KAutoObject* server_object);
/// Registers all kernel objects with the global emulation state, this is purely for tracking /// Registers all kernel objects with the global emulation state, this is purely for tracking
/// leaks after emulation has been shutdown. /// leaks after emulation has been shutdown.
void RegisterKernelObject(KAutoObject* object); void RegisterKernelObject(KAutoObject* object);

View File

@ -384,7 +384,6 @@ static Result ConnectToNamedPort(Core::System& system, Handle* out, VAddr port_n
// Create a session. // Create a session.
KClientSession* session{}; KClientSession* session{};
R_TRY(port->CreateSession(std::addressof(session))); R_TRY(port->CreateSession(std::addressof(session)));
port->Close();
kernel.RegisterNamedServiceHandler(port_name, &port->GetParent()->GetServerPort()); kernel.RegisterNamedServiceHandler(port_name, &port->GetParent()->GetServerPort());

View File

@ -101,7 +101,9 @@ ServiceFrameworkBase::~ServiceFrameworkBase() {
const auto guard = LockService(); const auto guard = LockService();
if (named_port != nullptr) { if (named_port != nullptr) {
named_port->Close(); named_port->GetClientPort().Close();
named_port->GetServerPort().Close();
named_port = nullptr;
} }
} }