This commit is contained in:
gjm committed 2026-09-28 22:13:47 +08:00
1 parent 5289689737
commit 1fdcdefef1
3 files changed
+36 -4

No files matched your search

+15 -3
View File
@@ -131,10 +131,21 @@ namespace mcp
bool init_mcp()
{
g_bRunning = true;
g_serverThread = std::thread(TcpServerLoop);
acutPrintf(_T("\n[MCP Server] 后台 TCP 监听线程已启动 (端口: 8080)...\n"));
try
{
g_serverThread = std::thread(TcpServerLoop);
acutPrintf(_T("\n[MCP Server] 后台 TCP 监听线程已启动 (端口: 8080)...\n"));
}
catch (const std::system_error &e)
{
// 线程创建失败,重置状态标志并输出错误
g_bRunning = false;
// e.what() 返回的是 const char*,所以在 acutPrintf 中要用 %hs 而不是 %s 或 %ls
acutPrintf(_T("\n[MCP Server] 致命错误:无法创建后台监听线程!原因: %hs\n"), e.what());
}
return g_bRunning;
}
bool close_mcp()
{
g_bRunning = false;
@@ -143,5 +154,6 @@ namespace mcp
g_serverThread.join();
}
acutPrintf(_T("\n[MCP Server] 插件已卸载,线程已关闭。\n"));
return true;
}
}