mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:37:44 +00:00
SystemServer: Make decision on whether to enable a service more readable
This change ensures that code in the Service class doesn't try to check the g_system_mode variable, but instead is asked on whether it supports a given system mode string value. Also, don't assume that we should create sockets for any new Service instance, but instead do that only if the Service should run in the current system mode.
This commit is contained in:
parent
41db527369
commit
9dbd22b555
3 changed files with 72 additions and 27 deletions
|
@ -359,16 +359,13 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
|
||||
ErrorOr<NonnullRefPtr<Service>> Service::try_create(Core::ConfigFile const& config, StringView name)
|
||||
{
|
||||
auto service = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Service(config, name)));
|
||||
if (service->is_enabled())
|
||||
TRY(service->setup_sockets());
|
||||
return service;
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Service(config, name)));
|
||||
}
|
||||
|
||||
bool Service::is_enabled() const
|
||||
bool Service::is_enabled_for_system_mode(StringView mode) const
|
||||
{
|
||||
extern DeprecatedString g_system_mode;
|
||||
return m_system_modes.contains_slow(g_system_mode);
|
||||
return m_system_modes.contains_slow(mode);
|
||||
}
|
||||
|
||||
ErrorOr<void> Service::determine_account(int fd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue