From 33986f48934bdc5f70c17d8ba6a47ac9a655ca8c Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Fri, 16 Oct 2026 21:08:42 +0200 Subject: [PATCH] Fix: shared-host respawn block and web login brand placeholder Two unrelated fixes bundled here. 1. Client respawn (ClientDll.cpp EasyRun/Run, test.cpp Run): after a host is shared or transferred to another server, restarting the master (server A) left the host's main instance stuck, because the respawn loop waited on IsStoped() (g_bThreadExit && GetCount()==0), which never becomes true while a still-alive shared instance holds AddCount(1). S_SERVER_EXIT now triggers an immediate reconnect without waiting for shared instances; client-exit / update still waits for all instances to drain. Verified by 100 restart cycles. 2. Web login page (WebService.cpp): the MFC web server only substituted __BASE_PATH__ in index.html and left __BRAND_NAME__ as a literal token in the login page title/heading. Substitute it with "SimpleRemoter" to match the original branding and the Go server's default. Co-Authored-By: deepseek-v4-pro --- client/ClientDll.cpp | 18 ++++++++---------- client/test.cpp | 8 ++++++-- server/2015Remote/WebService.cpp | 5 +++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/client/ClientDll.cpp b/client/ClientDll.cpp index 06a67f2..c982d21 100644 --- a/client/ClientDll.cpp +++ b/client/ClientDll.cpp @@ -462,14 +462,12 @@ extern "C" __declspec(dllexport) int EasyRun() do { TestRun((char*)settings.ServerIP(), settings.ServerPort()); + if (S_SERVER_EXIT == app.g_bExit) + continue; // 主控端重启:立即重连,不等仍存活的分享实例 + // 受控端退出 / 程序更新:等所有实例(含分享实例)退干净再退出 while (!IsStoped()) Sleep(50); - if (S_CLIENT_EXIT == app.g_bExit) // 受控端退出 - break; - else if (S_SERVER_EXIT == app.g_bExit) - continue; - else // S_CLIENT_UPDATE: 程序更新 - break; + break; } while (true); return app.g_bExit; @@ -555,14 +553,14 @@ extern "C" __declspec(dllexport) void Run(HWND hwnd, HINSTANCE hinst, LPSTR lpsz do { TestRun((char*)result[0].c_str(), atoi(result[1].c_str())); + if (bExit == S_SERVER_EXIT) + continue; // 主控端重启:立即重连,不等仍存活的分享实例 + // 受控端退出 / 程序更新:等所有实例(含分享实例)退干净 while (!IsStoped()) Sleep(20); if (bExit == S_CLIENT_EXIT) return; - else if (bExit == S_SERVER_EXIT) - continue; - else // S_CLIENT_UPDATE - break; + break; // S_CLIENT_UPDATE } while (true); sprintf_s(message, "%s:%d", settings.ServerIP(), settings.ServerPort()); diff --git a/client/test.cpp b/client/test.cpp index ad8a159..736b51c 100644 --- a/client/test.cpp +++ b/client/test.cpp @@ -495,8 +495,12 @@ BOOL Run(const char* argv1, int argv2, const std::string &runCmd) } do { run(ip, port); - while (bStop && !bStop() && 0 == status) - Sleep(20); + if (bExit && bExit() != S_SERVER_EXIT) { + // 受控端退出 / 程序更新:等所有实例(含分享实例)退干净,避免下方 FreeLibrary + // 卸载 DLL 时残留分享实例线程。主控端重启(S_SERVER_EXIT)则立即重连,不等仍存活的分享实例。 + while (bStop && !bStop() && 0 == status) + Sleep(20); + } } while (bExit && !bExit() && 0 == status); while (bStop && !bStop() && 1 == status) diff --git a/server/2015Remote/WebService.cpp b/server/2015Remote/WebService.cpp index e31bd5e..c58abc6 100644 --- a/server/2015Remote/WebService.cpp +++ b/server/2015Remote/WebService.cpp @@ -245,6 +245,11 @@ void CWebService::ServerThread(int port) { // server's subpath deployment. The MFC server serves from the domain root, // so strip it (→ "") — otherwise the WebSocket/CSS/JS URLs break. ReplaceAll(cachedHtml, "__BASE_PATH__", ""); + // server/web/index.html also carries a __BRAND_NAME__ placeholder for the + // white-label title. The Go server swaps it at serve time (defaulting to + // "SimpleRemoter"); the MFC server does the same here, otherwise the login + // page shows the literal "__BRAND_NAME__" token as