W17: extract ai_common shared module + fix anthropic data race + brace bugs
- New plugins_upper/ai_common/ static library: shared PluginConfig, ToolCallAccum, StreamContext, secure_zero, extract_host_port, serialize_tool_calls, free_chat_result - Refactored openai/anthropic plugins to use dstalk_ai:: namespace from ai_common - Fixed anthropic g_config raw pointer → std::atomic (data race) - Added SSE parse error counter with threshold abort (kMaxSseParseErrors=5) - Fixed missing closing brace in both plugins' error-body catch block - Updated test targets: ai_common include path + link, using namespace dstalk_ai - plugin_loader_test: added stub_unreg + service_registry.cpp for unregister_service - Includes pre-existing uncommitted changes from prior waves Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,7 @@ static void mock_log(int level, const char* fmt, ...) {
|
||||
// Stub host_api 函数:除 log 外所有操作均返回失败/默认值
|
||||
static int stub_reg(const char*, int, void*) { return -1; }
|
||||
static void* stub_query(const char*, int) { return nullptr; }
|
||||
static void stub_unreg(const char*) {}
|
||||
static int stub_sub(int, dstalk_event_handler_fn, void*) { return -1; }
|
||||
static int stub_emit(int, const void*) { return -1; }
|
||||
static void stub_unsub(int) {}
|
||||
@@ -67,7 +68,7 @@ static char* stub_strdup(const char*) { return nullptr; }
|
||||
// Mock host_api vtable: all stubs except mock_log for capturing error-path diagnostics
|
||||
// Mock host_api 虚表:除 mock_log 外全部 stub,用于捕获错误路径诊断
|
||||
static dstalk_host_api_t g_mock_host_api = {
|
||||
stub_reg, stub_query,
|
||||
stub_reg, stub_query, stub_unreg,
|
||||
stub_sub, stub_emit, stub_unsub,
|
||||
stub_cget, stub_cset,
|
||||
mock_log,
|
||||
@@ -148,8 +149,8 @@ int main()
|
||||
dstalk::PluginLoader loader;
|
||||
fs::path plugins_dir = get_plugins_dir();
|
||||
|
||||
fs::path dll_config = plugins_dir / "plugin-config.dll";
|
||||
fs::path dll_fileio = plugins_dir / "plugin-file_io.dll";
|
||||
fs::path dll_config = plugins_dir / "plugin_config.dll";
|
||||
fs::path dll_fileio = plugins_dir / "plugin_file_io.dll";
|
||||
|
||||
bool have_plugins = fs::exists(dll_config) && fs::exists(dll_fileio);
|
||||
|
||||
@@ -206,8 +207,8 @@ int main()
|
||||
fs::path plugins_dir = get_plugins_dir();
|
||||
|
||||
std::vector<fs::path> dlls;
|
||||
for (auto name : {"plugin-config.dll", "plugin-file_io.dll",
|
||||
"plugin-context.dll", "plugin-session.dll"}) {
|
||||
for (auto name : {"plugin_config.dll", "plugin_file_io.dll",
|
||||
"plugin_context.dll", "plugin_session.dll"}) {
|
||||
fs::path p = plugins_dir / name;
|
||||
if (fs::exists(p)) dlls.push_back(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user