diff options
| author | Dan Engelbrecht <[email protected]> | 2024-06-14 13:39:41 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-06-14 13:39:41 +0200 |
| commit | 1af67dd8fce02e0f3bb65bf1a0bee1922e118435 (patch) | |
| tree | 7b80403ac6ba2e158cdd27579ff90ce5f48ca6cb | |
| parent | 5.5.3 (diff) | |
| download | zen-1af67dd8fce02e0f3bb65bf1a0bee1922e118435.tar.xz zen-1af67dd8fce02e0f3bb65bf1a0bee1922e118435.zip | |
improve mutex startup error (#96)
* separate collision of shared mutex from failure to create shared mutex
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 9 |
2 files changed, 10 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b61ed99c..be3a1932f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ ## +- Improvement: Add better output/logging when failing to initialize shared mutex + +## 5.5.3 - Feature: New 'workspaces' service which allows a user to share a local folder via zenserver. A workspace can have mulitple workspace shares and they provie an HTTP API that is compatible with the project oplog HTTP API. Workspaces and shares are preserved between runs. Workspaces feature is disabled by default - enable with `--workspaces-enabled` option when launching zenserver. - New http service endpoint `/ws` - `/ws/{workspace_id}` - manage workspaces. {workspace_id} is a Object Id diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index 9f24960bd..48ea89204 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -8,6 +8,7 @@ #include <zencore/compactbinarybuilder.h> #include <zencore/compactbinaryvalidation.h> #include <zencore/config.h> +#include <zencore/except.h> #include <zencore/filesystem.h> #include <zencore/fmtutils.h> #include <zencore/iobuffer.h> @@ -148,9 +149,13 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen std::string MutexName = fmt::format("zen_{}", ServerOptions.BasePort); - if (NamedMutex::Exists(MutexName) || ((m_ServerMutex.Create(MutexName) == false))) + if (NamedMutex::Exists(MutexName)) { - throw std::runtime_error(fmt::format("Failed to create mutex '{}' - is another instance already running?", MutexName).c_str()); + throw std::runtime_error(fmt::format("Mutex '{}' already exists - is another instance already running?", MutexName).c_str()); + } + if (m_ServerMutex.Create(MutexName) == false) + { + ThrowLastError(fmt::format("Failed to create mutex '{}'", MutexName).c_str()); } InitializeState(ServerOptions); |