From 3aadaa3396248df87bb1cc07d8ed06a7658b8be8 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sat, 18 Jul 2026 15:41:02 +0300 Subject: [PATCH] fix: sqlite3_open wrong path in topo_group.c (db_path vs db_path/chats.db), keep separate connections for perf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - topo_group.c: open {db_path}/chats.db instead of {db_path} — was opening a directory - chat_core.c: remove inst->topo_sqlite_db = g_cc.db — keep topo_sqlite_db as separate uTun-only connection without FULLMUTEX, avoiding contention with GUI reads --- src/topo_group.c | 8 +++++--- tools/chatgui/transport/chat_core.c | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/topo_group.c b/src/topo_group.c index 192f8d56..96e9406f 100644 --- a/src/topo_group.c +++ b/src/topo_group.c @@ -254,15 +254,17 @@ struct TOPO_GROUPS* topo_groups_init(struct UTUN_INSTANCE* instance) { g->v6_subnet_pool = memory_pool_init(sizeof(struct TOPO_SUBNET6), "to_v6sub"); if (instance->config && instance->config->global.db_path[0]) { - int rc = sqlite3_open(instance->config->global.db_path, &instance->topo_sqlite_db); + char db_file[512]; + snprintf(db_file, sizeof(db_file), "%s/chats.db", instance->config->global.db_path); + int rc = sqlite3_open(db_file, &instance->topo_sqlite_db); if (rc == SQLITE_OK && instance->topo_sqlite_db) { sqlite3_exec(instance->topo_sqlite_db, "PRAGMA journal_mode=WAL", NULL, NULL, NULL); sqlite3_exec(instance->topo_sqlite_db, "PRAGMA foreign_keys=ON", NULL, NULL, NULL); topo_node_sqlite_init(instance->topo_sqlite_db); - DEBUG_INFO(DEBUG_CATEGORY_BGP, "SQLite opened: %s", instance->config->global.db_path); + DEBUG_INFO(DEBUG_CATEGORY_BGP, "SQLite opened: %s", db_file); } else { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "sqlite3_open(%s) failed: %s", - instance->config->global.db_path, instance->topo_sqlite_db ? sqlite3_errmsg(instance->topo_sqlite_db) : "null db"); + db_file, instance->topo_sqlite_db ? sqlite3_errmsg(instance->topo_sqlite_db) : "null db"); if (instance->topo_sqlite_db) { sqlite3_close(instance->topo_sqlite_db); instance->topo_sqlite_db = NULL; } } } diff --git a/tools/chatgui/transport/chat_core.c b/tools/chatgui/transport/chat_core.c index 607df578..a3012ad0 100644 --- a/tools/chatgui/transport/chat_core.c +++ b/tools/chatgui/transport/chat_core.c @@ -105,7 +105,6 @@ int chat_core_init(struct UTUN_INSTANCE* inst, const char* db_path) { g_cc.my_node_id = inst->node_id; topo_node_sqlite_init(g_cc.db); - inst->topo_sqlite_db = g_cc.db; /* записать себя в nodes + local_identity с реальным node_id и именем */ {