aboutsummaryrefslogtreecommitdiff
path: root/zenutil/include
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-16 21:08:47 +0200
committerStefan Boberg <[email protected]>2021-09-16 21:08:47 +0200
commit287f6280fcb32820f2c69def0bdced96d804429b (patch)
tree1e455261dcb84048ace2c072d47a0d63a6a0dbb1 /zenutil/include
parentAdded stubs for scrub CLI command (diff)
downloadzen-287f6280fcb32820f2c69def0bdced96d804429b.tar.xz
zen-287f6280fcb32820f2c69def0bdced96d804429b.zip
Changed how sponsor processes are managed
We can now monitor more than one process and if a new process is started on the same port we will hand over the owner pid to the process which is already executing before exiting. Note that this is only done if there is actually already an owner process in the instance list.
Diffstat (limited to 'zenutil/include')
-rw-r--r--zenutil/include/zenserverprocess.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenserverprocess.h
index b81d61c25..7fcacf788 100644
--- a/zenutil/include/zenserverprocess.h
+++ b/zenutil/include/zenserverprocess.h
@@ -10,6 +10,7 @@
#include <atomic>
#include <filesystem>
+#include <optional>
class ZenServerEnvironment
{
@@ -44,6 +45,9 @@ struct ZenServerInstance
[[nodiscard]] bool WaitUntilReady(int Timeout);
void EnableTermination() { m_Terminate = true; }
void EnableMesh() { m_MeshEnabled = true; }
+ void Detach();
+ inline int GetPid() { return m_Process.Pid(); }
+ inline void SetOwnerPid(int Pid) { m_OwnerPid = Pid; }
void SetTestDir(std::filesystem::path TestDir)
{
@@ -66,6 +70,7 @@ private:
std::filesystem::path m_TestDir;
bool m_MeshEnabled = false;
int m_BasePort = 0;
+ std::optional<int> m_OwnerPid;
void CreateShutdownEvent(int BasePort);
};
@@ -90,7 +95,9 @@ public:
std::atomic<uint16_t> ListenPort;
std::atomic<uint16_t> Flags;
uint8_t SessionId[12];
+ std::atomic<uint32_t> SponsorPids[32];
uint8_t Padding[12];
+ uint8_t Padding2[96];
enum class FlagsEnum : uint16_t
{
@@ -101,9 +108,10 @@ public:
void Reset();
void SignalShutdownRequest();
+ bool AddSponsorProcess(uint32_t Pid);
};
- static_assert(sizeof(ZenServerEntry) == 32);
+ static_assert(sizeof(ZenServerEntry) == 256);
void Initialize();
[[nodiscard]] bool InitializeReadOnly();
@@ -115,6 +123,6 @@ public:
private:
void* m_hMapFile = nullptr;
ZenServerEntry* m_Data;
- int m_MaxEntryCount = 4096 / sizeof(ZenServerEntry);
+ int m_MaxEntryCount = 131072 / sizeof(ZenServerEntry);
ZenServerEntry* m_OurEntry = nullptr;
};