service_manager: auto subscribe

This commit is contained in:
TuxSH 2019-03-28 22:56:13 +01:00
parent 8345f31c2a
commit 74bbfb95d3

View File

@ -53,6 +53,14 @@ Result ServiceManager_Run(const ServiceManagerServiceEntry *services, const Serv
TRY(srvEnableNotification(&waitHandles[0])); TRY(srvEnableNotification(&waitHandles[0]));
// Subscribe to notifications if needed.
for (u32 i = 0; notifications[i].handler != NULL; i++) {
// Termination & ready for reboot events send by PM using PublishToProcess don't require subscription.
if (notifications[i].id != 0x100 && notifications[i].id != 0x179) {
TRY(srvSubscribe(notifications[i].id));
}
}
for (u32 i = 0; i < numServices; i++) { for (u32 i = 0; i < numServices; i++) {
if (!services[i].isGlobalPort) { if (!services[i].isGlobalPort) {
TRY(srvRegisterService(&waitHandles[1 + i], services[i].name, (s32)services[i].maxSessions)); TRY(srvRegisterService(&waitHandles[1 + i], services[i].name, (s32)services[i].maxSessions));
@ -150,6 +158,14 @@ cleanup:
svcCloseHandle(waitHandles[i]); svcCloseHandle(waitHandles[i]);
} }
// Subscribe to notifications if needed.
for (u32 i = 0; notifications[i].handler != NULL; i++) {
// Termination & ready for reboot events send by PM using PublishToProcess don't require subscription.
if (notifications[i].id != 0x100 && notifications[i].id != 0x179) {
TRY(srvUnsubscribe(notifications[i].id));
}
}
for (u32 i = 0; i < numServices; i++) { for (u32 i = 0; i < numServices; i++) {
if (!services[i].isGlobalPort) { if (!services[i].isGlobalPort) {
srvUnregisterService(services[i].name); srvUnregisterService(services[i].name);