|
|
@ -96,15 +96,15 @@ struct KernelCore::Impl {
|
|
|
|
|
|
|
|
|
|
|
|
process_list.clear();
|
|
|
|
process_list.clear();
|
|
|
|
|
|
|
|
|
|
|
|
// Close all open server ports.
|
|
|
|
// Close all open server sessions and ports.
|
|
|
|
std::unordered_set<KServerPort*> server_ports_;
|
|
|
|
std::unordered_set<KAutoObject*> server_objects_;
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::scoped_lock lk{server_ports_lock};
|
|
|
|
std::scoped_lock lk(server_objects_lock);
|
|
|
|
server_ports_ = server_ports;
|
|
|
|
server_objects_ = server_objects;
|
|
|
|
server_ports.clear();
|
|
|
|
server_objects.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (auto* server_port : server_ports_) {
|
|
|
|
for (auto* server_object : server_objects_) {
|
|
|
|
server_port->Close();
|
|
|
|
server_object->Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Ensures all service threads gracefully shutdown.
|
|
|
|
// Ensures all service threads gracefully shutdown.
|
|
|
@ -659,13 +659,20 @@ struct KernelCore::Impl {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
KClientPort* port = &search->second(system.ServiceManager(), system);
|
|
|
|
KClientPort* port = &search->second(system.ServiceManager(), system);
|
|
|
|
{
|
|
|
|
RegisterServerObject(&port->GetParent()->GetServerPort());
|
|
|
|
std::scoped_lock lk{server_ports_lock};
|
|
|
|
|
|
|
|
server_ports.insert(&port->GetParent()->GetServerPort());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return port;
|
|
|
|
return 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, 1, name);
|
|
|
|
auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, 1, name);
|
|
|
@ -693,7 +700,7 @@ struct KernelCore::Impl {
|
|
|
|
service_threads_manager.QueueWork([this]() { service_threads.clear(); });
|
|
|
|
service_threads_manager.QueueWork([this]() { service_threads.clear(); });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::mutex server_ports_lock;
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
@ -723,7 +730,7 @@ struct KernelCore::Impl {
|
|
|
|
/// the ConnectToPort SVC.
|
|
|
|
/// the ConnectToPort SVC.
|
|
|
|
std::unordered_map<std::string, ServiceInterfaceFactory> service_interface_factory;
|
|
|
|
std::unordered_map<std::string, ServiceInterfaceFactory> service_interface_factory;
|
|
|
|
NamedPortTable named_ports;
|
|
|
|
NamedPortTable named_ports;
|
|
|
|
std::unordered_set<KServerPort*> server_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;
|
|
|
|
|
|
|
|
|
|
|
@ -928,6 +935,14 @@ KClientPort* KernelCore::CreateNamedServicePort(std::string name) {
|
|
|
|
return impl->CreateNamedServicePort(std::move(name));
|
|
|
|
return impl->CreateNamedServicePort(std::move(name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|