aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/zenserverprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenutil/zenserverprocess.cpp')
-rw-r--r--src/zenutil/zenserverprocess.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/zenutil/zenserverprocess.cpp b/src/zenutil/zenserverprocess.cpp
index 3667ad2c6..7725d0af6 100644
--- a/src/zenutil/zenserverprocess.cpp
+++ b/src/zenutil/zenserverprocess.cpp
@@ -308,7 +308,7 @@ ZenServerState::Sweep()
if (Entry.DesiredListenPort)
{
- if (IsProcessRunning(Entry.Pid) == false)
+ if (Entry.Pid != 0 && IsProcessRunning(Entry.Pid) == false)
{
ZEN_DEBUG("Sweep - pid {} not running, reclaiming entry (port {})", Entry.Pid.load(), Entry.DesiredListenPort.load());
@@ -363,18 +363,15 @@ ZenServerState::ZenServerEntry::AddSponsorProcess(uint32_t PidToAdd)
{
for (std::atomic<uint32_t>& PidEntry : SponsorPids)
{
- if (PidEntry.load(std::memory_order_relaxed) == 0)
+ if (PidEntry.load(std::memory_order_relaxed) == PidToAdd)
{
- uint32_t Expected = 0;
- if (PidEntry.compare_exchange_strong(Expected, PidToAdd))
- {
- // Success!
- return true;
- }
+ // Success, the because pid is already in the list
+ return true;
}
- else if (PidEntry.load(std::memory_order_relaxed) == PidToAdd)
+ uint32_t Expected = 0;
+ if (PidEntry.compare_exchange_strong(Expected, PidToAdd))
{
- // Success, the because pid is already in the list
+ // Success!
return true;
}
}