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
This commit is contained in:
yuanyuanxianganddeepseek-v4-pro committed 2026-10-16 21:08:42 +02:00
1 parent e5f5720867
commit 33986f4893
3 files changed
+19 -12

No files matched your search

+8 -10
View File
@@ -462,14 +462,12 @@ extern "C" __declspec(dllexport) int EasyRun()
do { do {
TestRun((char*)settings.ServerIP(), settings.ServerPort()); TestRun((char*)settings.ServerIP(), settings.ServerPort());
if (S_SERVER_EXIT == app.g_bExit)
continue; // 主控端重启:立即重连,不等仍存活的分享实例
// 受控端退出 / 程序更新:等所有实例(含分享实例)退干净再退出
while (!IsStoped()) while (!IsStoped())
Sleep(50); Sleep(50);
if (S_CLIENT_EXIT == app.g_bExit) // 受控端退出 break;
break;
else if (S_SERVER_EXIT == app.g_bExit)
continue;
else // S_CLIENT_UPDATE: 程序更新
break;
} while (true); } while (true);
return app.g_bExit; return app.g_bExit;
@@ -555,14 +553,14 @@ extern "C" __declspec(dllexport) void Run(HWND hwnd, HINSTANCE hinst, LPSTR lpsz
do { do {
TestRun((char*)result[0].c_str(), atoi(result[1].c_str())); TestRun((char*)result[0].c_str(), atoi(result[1].c_str()));
if (bExit == S_SERVER_EXIT)
continue; // 主控端重启:立即重连,不等仍存活的分享实例
// 受控端退出 / 程序更新:等所有实例(含分享实例)退干净
while (!IsStoped()) while (!IsStoped())
Sleep(20); Sleep(20);
if (bExit == S_CLIENT_EXIT) if (bExit == S_CLIENT_EXIT)
return; return;
else if (bExit == S_SERVER_EXIT) break; // S_CLIENT_UPDATE
continue;
else // S_CLIENT_UPDATE
break;
} while (true); } while (true);
sprintf_s(message, "%s:%d", settings.ServerIP(), settings.ServerPort()); sprintf_s(message, "%s:%d", settings.ServerIP(), settings.ServerPort());
+6 -2
View File
@@ -495,8 +495,12 @@ BOOL Run(const char* argv1, int argv2, const std::string &runCmd)
} }
do { do {
run(ip, port); run(ip, port);
while (bStop && !bStop() && 0 == status) if (bExit && bExit() != S_SERVER_EXIT) {
Sleep(20); // 受控端退出 / 程序更新:等所有实例(含分享实例)退干净,避免下方 FreeLibrary
// 卸载 DLL 时残留分享实例线程。主控端重启(S_SERVER_EXIT)则立即重连,不等仍存活的分享实例。
while (bStop && !bStop() && 0 == status)
Sleep(20);
}
} while (bExit && !bExit() && 0 == status); } while (bExit && !bExit() && 0 == status);
while (bStop && !bStop() && 1 == status) while (bStop && !bStop() && 1 == status)
+5
View File
@@ -245,6 +245,11 @@ void CWebService::ServerThread(int port) {
// server's subpath deployment. The MFC server serves from the domain root, // server's subpath deployment. The MFC server serves from the domain root,
// so strip it (→ "") — otherwise the WebSocket/CSS/JS URLs break. // so strip it (→ "") — otherwise the WebSocket/CSS/JS URLs break.
ReplaceAll(cachedHtml, "__BASE_PATH__", ""); 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 <title>/<h1>.
ReplaceAll(cachedHtml, "__BRAND_NAME__", "SimpleRemoter");
// Log loaded size; zero bytes means the RC BINARY resource is missing or // Log loaded size; zero bytes means the RC BINARY resource is missing or
// server/web/index.html was not embedded — check 2015Remote.rc and rebuild. // server/web/index.html was not embedded — check 2015Remote.rc and rebuild.
Mprintf("[WebService] index.html loaded: %zu bytes\n", cachedHtml.size()); Mprintf("[WebService] index.html loaded: %zu bytes\n", cachedHtml.size());