Fix: keep the in-process test client alive on compression switch

Switching wire compression used to set g_bExit = S_CLIENT_UPDATE and
disconnect. Standalone clients restart fine, but the in-process test
client (ServerDll loaded with MemoryModule) only restarts AutoRun on
S_SERVER_EXIT; S_CLIENT_UPDATE made TestRun return and AutoRun exit, so
the host went offline for good and the "Run Test Program" menu stayed
disabled.

The command handler now disconnects and calls
IOCPClient::SetWireCompression() on the existing connection object.
The reconnect loop reuses it with the new mode; sub-connections are
rebuilt from the saved config after the main link reconnects. g_bExit
is no longer touched.

The experimental menu gains two 16x16 icons (blue Z for zstd, orange L
for zlib) and grays the algorithm the selected hosts already use
(all-zstd grays ZSTD, all-zlib grays ZLIB, mixed leaves both enabled,
unsupported clients gray both). The new strings are translated in the
en_US, de_DE and zh_TW packs (the German pack also gained the missing
"Experimental" group title).

Verified: with an isolated Debug server, the in-process test client
switches zstd -> zlib -> zstd, reconnects in about 3 s each time and
keeps receiving MasterSettings; the menu reports the expected gray
state and icons in a captured screenshot.

Co-Authored-By: deepseek-flash
This commit was merged in pull request #9.
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-24 10:33:42 +01:00
1 parent 0e20e0bbdb
commit e6a3255a2b
13 files changed
+74 -17

No files matched your search

+6 -2
View File
@@ -210,6 +210,10 @@ public:
return OnServerSending(szBuffer, ulOriginalLength, mask);
}
// 切换线缆压缩模式。只影响下一次建连(调用方随后 Disconnect,重连循环复用本对象);
// COMMAND_SET_COMPRESS 用它原地切换,避免 S_CLIENT_UPDATE 把进程内测试客户端停死。
void SetWireCompression(bool useZlib) { m_useZlib = useZlib; }
void SetServerAddress(const char* szServerIP, unsigned short uPort)
{
m_Domain = szServerIP ? szServerIP : "127.0.0.1";
@@ -438,8 +442,8 @@ protected:
bool m_subConnAuthEnabled = false;
uint64_t m_subConnAuthClientID = 0; // 0 表示从 m_conn->clientID 现取
// 线缆压缩:运行期由 settings\compress 选择(默认 zstd;配置 zlib 时用 zlib)。
// 每个连接实例在构造时读取一次;COMMAND_SET_COMPRESS 触发重连后重新读取。
// 线缆压缩:本连接构造时读 settings\compress(默认 zstd;配置 zlib 时用 zlib);
// COMMAND_SET_COMPRESS 通过 SetWireCompression() 原地改写,下一次建连生效。
bool m_useZlib = false;
bool CompressData(BYTE* dst, ULONG& dstLen, const void* src, ULONG srcLen);
bool DecompressData(BYTE* dst, ULONG& dstLen, const void* src, ULONG srcLen);