@ -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 " ) ;
g - > v6_subnet_pool = memory_pool_init ( sizeof ( struct TOPO_SUBNET6 ) , " to_v6sub " ) ;
if ( instance - > config & & instance - > config - > global . db_path [ 0 ] ) {
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 ) {
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 journal_mode=WAL " , NULL , NULL , NULL ) ;
sqlite3_exec ( instance - > topo_sqlite_db , " PRAGMA foreign_keys=ON " , NULL , NULL , NULL ) ;
sqlite3_exec ( instance - > topo_sqlite_db , " PRAGMA foreign_keys=ON " , NULL , NULL , NULL ) ;
topo_node_sqlite_init ( instance - > topo_sqlite_db ) ;
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 {
} else {
DEBUG_ERROR ( DEBUG_CATEGORY_BGP , " sqlite3_open(%s) failed: %s " ,
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 ; }
if ( instance - > topo_sqlite_db ) { sqlite3_close ( instance - > topo_sqlite_db ) ; instance - > topo_sqlite_db = NULL ; }
}
}
}
}