aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2025-08-04 09:49:15 +0200
committerGitHub Enterprise <[email protected]>2025-08-04 09:49:15 +0200
commitd1b80c4a6ee6c052985110120f90b4f983d966a6 (patch)
treed6f3469e27d1d6d9273574622a8e2699dc441454 /src/zenserver/main.cpp
parent5.6.14 (diff)
downloadzen-d1b80c4a6ee6c052985110120f90b4f983d966a6.tar.xz
zen-d1b80c4a6ee6c052985110120f90b4f983d966a6.zip
Set ready event when reusing an existing server instance. (#448)
* Moved firing of child-id event into a lambda * Fire notify event to parent after attaching to an existing instance * Updated changelog
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index b0d945814..6d9a478be 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -117,6 +117,14 @@ ZenEntryPoint::Run()
ServerState.Initialize();
ServerState.Sweep();
+ auto NotifyReady = [&] {
+ if (!m_ServerOptions.ChildId.empty())
+ {
+ NamedEvent ParentEvent{m_ServerOptions.ChildId};
+ ParentEvent.Set();
+ }
+ };
+
uint32_t AttachSponsorProcessRetriesLeft = 3;
ZenServerState::ZenServerEntry* Entry = ServerState.Lookup(m_ServerOptions.BasePort);
while (Entry)
@@ -155,6 +163,7 @@ ZenEntryPoint::Run()
// Sponsor processes are checked every second, so 2 second wait time should be enough
if (Entry->AddSponsorProcess(m_ServerOptions.OwnerPid, 2000))
{
+ NotifyReady();
std::exit(0);
}
if (AttachSponsorProcessRetriesLeft-- > 0)
@@ -294,12 +303,7 @@ ZenEntryPoint::Run()
Server.SetIsReadyFunc([&] {
m_LockFile.Update(MakeLockData(true), Ec);
-
- if (!m_ServerOptions.ChildId.empty())
- {
- NamedEvent ParentEvent{m_ServerOptions.ChildId};
- ParentEvent.Set();
- }
+ NotifyReady();
});
Server.Run();