From 06e55d6394c5d03fb7364971d3fbfced73ed6d34 Mon Sep 17 00:00:00 2001 From: DanS Date: Thu, 16 Jul 2026 18:42:10 -0500 Subject: [PATCH] feat(app): per-variant single-instance lock so full node + Lite can run together MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- src/main.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8bb352a..961cb2b 100644 --- a/src/main.cpp +++ b/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); #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"); +#endif // Check for payment URI in command line args static std::string findPaymentURI(int argc, char* argv[]) @@ -764,11 +769,12 @@ int main(int argc, char* argv[]) // Check for existing instance 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"); #ifdef _WIN32 - MessageBoxW(nullptr, L"Another instance of ObsidianDragon is already running.\nPlease close it first.", - L"ObsidianDragon", MB_OK | MB_ICONINFORMATION); + const std::string msg = std::string("Another instance of ") + DRAGONX_APP_NAME + + " is already running.\nPlease close it first."; + MessageBoxA(nullptr, msg.c_str(), DRAGONX_APP_NAME, MB_OK | MB_ICONINFORMATION); #endif return 1; }