stratosphere: prefer static waitable managers

This commit is contained in:
Michael Scire 2019-06-20 13:15:39 -07:00
parent d3d6c552b7
commit 1671c04e24
10 changed files with 39 additions and 64 deletions

View file

@ -38,23 +38,20 @@ void BpcMitmMain(void *arg) {
BpcRebootManager::Initialize(); BpcRebootManager::Initialize();
/* Create server manager */ /* Create server manager */
auto server_manager = new WaitableManager(2); static auto s_server_manager = WaitableManager(2);
/* Create bpc mitm. */ /* Create bpc mitm. */
const char *service_name = "bpc"; const char *service_name = "bpc";
if (GetRuntimeFirmwareVersion() < FirmwareVersion_200) { if (GetRuntimeFirmwareVersion() < FirmwareVersion_200) {
service_name = "bpc:c"; service_name = "bpc:c";
} }
AddMitmServerToManager<BpcMitmService>(server_manager, service_name, 13); AddMitmServerToManager<BpcMitmService>(&s_server_manager, service_name, 13);
/* Extension: Allow for reboot-to-error. */ /* Extension: Allow for reboot-to-error. */
/* Must be managed port in order for sm to be able to access. */ /* Must be managed port in order for sm to be able to access. */
server_manager->AddWaitable(new ManagedPortServer<BpcAtmosphereService>("bpc:ams", 1)); s_server_manager.AddWaitable(new ManagedPortServer<BpcAtmosphereService>("bpc:ams", 1));
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
} }

View file

@ -37,14 +37,12 @@ using FsMitmManager = WaitableManager<FsMitmManagerOptions>;
void FsMitmMain(void *arg) { void FsMitmMain(void *arg) {
/* Create server manager. */ /* Create server manager. */
auto server_manager = new FsMitmManager(5); static auto s_server_manager = FsMitmManager(5);
/* Create fsp-srv mitm. */ /* Create fsp-srv mitm. */
AddMitmServerToManager<FsMitmService>(server_manager, "fsp-srv", 61); AddMitmServerToManager<FsMitmService>(&s_server_manager, "fsp-srv", 61);
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
} }

View file

@ -41,19 +41,16 @@ void NsMitmMain(void *arg) {
nsExit(); nsExit();
/* Create server manager */ /* Create server manager */
auto server_manager = new WaitableManager(1); static auto s_server_manager = WaitableManager(1);
/* Create ns mitm. */ /* Create ns mitm. */
if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) { if (GetRuntimeFirmwareVersion() < FirmwareVersion_300) {
AddMitmServerToManager<NsAmMitmService>(server_manager, "ns:am", 5); AddMitmServerToManager<NsAmMitmService>(&s_server_manager, "ns:am", 5);
} else { } else {
AddMitmServerToManager<NsWebMitmService>(server_manager, "ns:web", 5); AddMitmServerToManager<NsWebMitmService>(&s_server_manager, "ns:web", 5);
} }
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
} }

View file

@ -48,18 +48,15 @@ void SetMitmMain(void *arg) {
VersionManager::Initialize(); VersionManager::Initialize();
/* Create server manager */ /* Create server manager */
auto server_manager = new SetMitmManager(4); static auto s_server_manager = SetMitmManager(4);
/* Create set:sys mitm. */ /* Create set:sys mitm. */
AddMitmServerToManager<SetSysMitmService>(server_manager, "set:sys", 60); AddMitmServerToManager<SetSysMitmService>(&s_server_manager, "set:sys", 60);
/* Create set mitm. */ /* Create set mitm. */
AddMitmServerToManager<SetMitmService>(server_manager, "set", 60); AddMitmServerToManager<SetMitmService>(&s_server_manager, "set", 60);
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
} }

View file

@ -987,8 +987,8 @@ void DmntCheatManager::OnNewApplicationLaunch() {
} }
void DmntCheatManager::DetectThread(void *arg) { void DmntCheatManager::DetectThread(void *arg) {
auto waiter = new WaitableManager(1); static auto s_waiter = WaitableManager(1);
waiter->AddWaitable(LoadReadOnlySystemEvent(PrepareDebugNextApplication(), [](u64 timeout) { s_waiter.AddWaitable(LoadReadOnlySystemEvent(PrepareDebugNextApplication(), [](u64 timeout) {
/* Process stuff for new application. */ /* Process stuff for new application. */
DmntCheatManager::OnNewApplicationLaunch(); DmntCheatManager::OnNewApplicationLaunch();
@ -998,8 +998,7 @@ void DmntCheatManager::DetectThread(void *arg) {
return ResultSuccess; return ResultSuccess;
}, true)); }, true));
waiter->Process(); s_waiter.Process();
delete waiter;
} }
void DmntCheatManager::VmThread(void *arg) { void DmntCheatManager::VmThread(void *arg) {
@ -1092,16 +1091,10 @@ void DmntCheatManager::InitializeCheatManager() {
DmntCheatDebugEventsManager::Initialize(); DmntCheatDebugEventsManager::Initialize();
/* Spawn application detection thread, spawn cheat vm thread. */ /* Spawn application detection thread, spawn cheat vm thread. */
if (R_FAILED(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39))) { R_ASSERT(g_detect_thread.Initialize(&DmntCheatManager::DetectThread, nullptr, 0x4000, 39));
std::abort(); R_ASSERT(g_vm_thread.Initialize(&DmntCheatManager::VmThread, nullptr, 0x4000, 48));
}
if (R_FAILED(g_vm_thread.Initialize(&DmntCheatManager::VmThread, nullptr, 0x4000, 48))) {
std::abort();
}
/* Start threads. */ /* Start threads. */
if (R_FAILED(g_detect_thread.Start()) || R_FAILED(g_vm_thread.Start())) { R_ASSERT(g_detect_thread.Start());
std::abort(); R_ASSERT(g_vm_thread.Start());
}
} }

View file

@ -106,7 +106,7 @@ int main(int argc, char **argv)
DmntCheatManager::InitializeCheatManager(); DmntCheatManager::InitializeCheatManager();
/* Nintendo uses four threads. Add a fifth for our cheat service. */ /* Nintendo uses four threads. Add a fifth for our cheat service. */
auto server_manager = new WaitableManager(5); static auto s_server_manager = WaitableManager(5);
/* Create services. */ /* Create services. */
@ -114,12 +114,10 @@ int main(int argc, char **argv)
/* server_manager->AddWaitable(new ServiceServer<DebugMonitorService>("dmnt:-", 4)); */ /* server_manager->AddWaitable(new ServiceServer<DebugMonitorService>("dmnt:-", 4)); */
server_manager->AddWaitable(new ServiceServer<DmntCheatService>("dmnt:cht", 1)); s_server_manager.AddWaitable(new ServiceServer<DmntCheatService>("dmnt:cht", 1));
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
return 0; return 0;
} }

View file

@ -135,17 +135,15 @@ int main(int argc, char **argv)
CheckRepairStatus(); CheckRepairStatus();
/* TODO: What's a good timeout value to use here? */ /* TODO: What's a good timeout value to use here? */
auto server_manager = new WaitableManager(1); static auto s_server_manager = WaitableManager(1);
/* Create services. */ /* Create services. */
server_manager->AddWaitable(new ServiceServer<PrivateService>("fatal:p", 4)); s_server_manager.AddWaitable(new ServiceServer<PrivateService>("fatal:p", 4));
server_manager->AddWaitable(new ServiceServer<UserService>("fatal:u", 4)); s_server_manager.AddWaitable(new ServiceServer<UserService>("fatal:u", 4));
server_manager->AddWaitable(GetFatalSettingsEvent()); s_server_manager.AddWaitable(GetFatalSettingsEvent());
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
delete server_manager;
return 0; return 0;
} }

@ -1 +1 @@
Subproject commit 59b49c0e0c64f896ce36180bb7d00f54f70300e9 Subproject commit 4ccee4257763373c8e8dd5453246a592482f9a86

View file

@ -21,11 +21,9 @@
void ProcessTracking::MainLoop(void *arg) { void ProcessTracking::MainLoop(void *arg) {
/* Make a new waitable manager. */ /* Make a new waitable manager. */
auto process_waiter = new WaitableManager(1); static auto s_process_waiter = WaitableManager(1);
process_waiter->AddWaitable(Registration::GetProcessLaunchStartEvent()); s_process_waiter.AddWaitable(Registration::GetProcessLaunchStartEvent());
/* Service processes. */ /* Service processes. */
process_waiter->Process(); s_process_waiter.Process();
delete process_waiter;
} }

View file

@ -83,30 +83,29 @@ int main(int argc, char **argv)
consoleDebugInit(debugDevice_SVC); consoleDebugInit(debugDevice_SVC);
/* TODO: What's a good timeout value to use here? */ /* TODO: What's a good timeout value to use here? */
auto server_manager = new WaitableManager(1); static auto s_server_manager = WaitableManager(1);
/* Create sm:, (and thus allow things to register to it). */ /* Create sm:, (and thus allow things to register to it). */
server_manager->AddWaitable(new ManagedPortServer<UserService>("sm:", 0x40)); s_server_manager.AddWaitable(new ManagedPortServer<UserService>("sm:", 0x40));
/* Create sm:m manually. */ /* Create sm:m manually. */
Handle smm_h; Handle smm_h;
R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h)); R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:m"), 1, false, &smm_h));
server_manager->AddWaitable(new ExistingPortServer<ManagerService>(smm_h, 1)); s_server_manager.AddWaitable(new ExistingPortServer<ManagerService>(smm_h, 1));
/*===== ATMOSPHERE EXTENSION =====*/ /*===== ATMOSPHERE EXTENSION =====*/
/* Create sm:dmnt manually. */ /* Create sm:dmnt manually. */
Handle smdmnt_h; Handle smdmnt_h;
R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h)); R_ASSERT(Registration::RegisterServiceForSelf(smEncodeName("sm:dmnt"), 1, false, &smdmnt_h));
server_manager->AddWaitable(new ExistingPortServer<DmntService>(smm_h, 1));; s_server_manager.AddWaitable(new ExistingPortServer<DmntService>(smm_h, 1));;
/*================================*/ /*================================*/
/* Loop forever, servicing our services. */ /* Loop forever, servicing our services. */
server_manager->Process(); s_server_manager.Process();
/* Cleanup. */ /* Cleanup. */
delete server_manager;
return 0; return 0;
} }