feat(app): per-variant single-instance lock so full node + Lite can run together
The single-instance lock hardcoded the name "obsidiandragon" for both variants, so launching ObsidianDragonLite while ObsidianDragon was running (or vice-versa) was refused with "Another instance is already running". Nothing else actually required them to be exclusive — DRAGONX_APP_NAME already gives each variant its own config dir (settings / wallets index / address book / chat db), the full node's daemon lives under ~/.hush/DRAGONX with no Lite counterpart, and the lock guards no cross-instance IPC (the payment URI is handled locally). Key the lock per variant (obsidiandragon / obsidiandragonlite) — the Windows named mutex already derives from the same name, so it's fixed on both platforms. Each variant still enforces a single instance of itself. Also make the already-running message report the actual variant (DRAGONX_APP_NAME) and use MessageBoxA so it can. mingw-verified. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
14
src/main.cpp
14
src/main.cpp
@@ -439,8 +439,13 @@ static bool InitImGui(SDL_Window* window, SDL_GLContext gl_context);
|
|||||||
static void Shutdown(SDL_Window* window, SDL_GLContext gl_context);
|
static void Shutdown(SDL_Window* window, SDL_GLContext gl_context);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Global single instance lock
|
// Global single instance lock. Keyed PER VARIANT so the full node and Lite can run side by side —
|
||||||
|
// their config dirs are already separate (DRAGONX_APP_NAME), so only this lock kept them apart.
|
||||||
|
#ifdef DRAGONX_LITE_BUILD
|
||||||
|
static dragonx::util::SingleInstance g_single_instance("obsidiandragonlite");
|
||||||
|
#else
|
||||||
static dragonx::util::SingleInstance g_single_instance("obsidiandragon");
|
static dragonx::util::SingleInstance g_single_instance("obsidiandragon");
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check for payment URI in command line args
|
// Check for payment URI in command line args
|
||||||
static std::string findPaymentURI(int argc, char* argv[])
|
static std::string findPaymentURI(int argc, char* argv[])
|
||||||
@@ -764,11 +769,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Check for existing instance
|
// Check for existing instance
|
||||||
if (!g_single_instance.tryLock()) {
|
if (!g_single_instance.tryLock()) {
|
||||||
fprintf(stderr, "Another instance of ObsidianDragon is already running.\n");
|
fprintf(stderr, "Another instance of %s is already running.\n", DRAGONX_APP_NAME);
|
||||||
DEBUG_LOGF("Please close the existing instance first.\n");
|
DEBUG_LOGF("Please close the existing instance first.\n");
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MessageBoxW(nullptr, L"Another instance of ObsidianDragon is already running.\nPlease close it first.",
|
const std::string msg = std::string("Another instance of ") + DRAGONX_APP_NAME +
|
||||||
L"ObsidianDragon", MB_OK | MB_ICONINFORMATION);
|
" is already running.\nPlease close it first.";
|
||||||
|
MessageBoxA(nullptr, msg.c_str(), DRAGONX_APP_NAME, MB_OK | MB_ICONINFORMATION);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user