diff options
| author | Stefan Boberg <[email protected]> | 2021-10-27 21:01:50 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-27 21:01:50 +0200 |
| commit | 3bbb0d326bec3b3379c831b6a4cdc00438ac67f5 (patch) | |
| tree | 7e94bcb4bb4077aeb68663017695b582ebc9b149 /zenutil/include | |
| parent | Fixed crash at startup when updating manifest. (diff) | |
| download | zen-3bbb0d326bec3b3379c831b6a4cdc00438ac67f5.tar.xz zen-3bbb0d326bec3b3379c831b6a4cdc00438ac67f5.zip | |
Lockfile implementation (#24)
Implemented lockfile synchronization
To be used instead of or in conjunction with existing events to coordinate launching and discovery of server instances
Diffstat (limited to 'zenutil/include')
| -rw-r--r-- | zenutil/include/zenutil/zenserverprocess.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/zenutil/include/zenutil/zenserverprocess.h b/zenutil/include/zenutil/zenserverprocess.h index 09728aa1a..8a4f9604d 100644 --- a/zenutil/include/zenutil/zenserverprocess.h +++ b/zenutil/include/zenutil/zenserverprocess.h @@ -94,17 +94,22 @@ public: struct ZenServerEntry { + // NOTE: any changes to this should consider backwards compatibility + // which means you should not rearrange members only potentially + // add something to the end or use a different mechanism for + // additional state. For example, you can use the session ID + // to introduce additional named objects std::atomic<uint32_t> Pid; std::atomic<uint16_t> ListenPort; std::atomic<uint16_t> Flags; uint8_t SessionId[12]; - std::atomic<uint32_t> SponsorPids[32]; + std::atomic<uint32_t> SponsorPids[8]; uint8_t Padding[12]; - uint8_t Padding2[96]; enum class FlagsEnum : uint16_t { - kShutdownPlease = 1 << 0 + kShutdownPlease = 1 << 0, + kIsReady = 1 << 1, }; FRIEND_ENUM_CLASS_FLAGS(FlagsEnum); @@ -112,10 +117,11 @@ public: Oid GetSessionId() const { return Oid::FromMemory(SessionId); } void Reset(); void SignalShutdownRequest(); + void SignalReady(); bool AddSponsorProcess(uint32_t Pid); }; - static_assert(sizeof(ZenServerEntry) == 256); + static_assert(sizeof(ZenServerEntry) == 64); void Initialize(); [[nodiscard]] bool InitializeReadOnly(); @@ -128,7 +134,7 @@ public: private: void* m_hMapFile = nullptr; ZenServerEntry* m_Data = nullptr; - int m_MaxEntryCount = 131072 / sizeof(ZenServerEntry); + int m_MaxEntryCount = 65536 / sizeof(ZenServerEntry); ZenServerEntry* m_OurEntry = nullptr; bool m_IsReadOnly = true; }; |