fix: sqlite3_open wrong path in topo_group.c (db_path vs db_path/chats.db), keep separate connections for perf
- 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
This commit is contained in:
1 parent
9245a30fa5
commit
3aadaa3396
2 files changed
+5
-4
No files matched your search
+5
-3
@@ -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; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user