sergey-safarov created an issue (kamailio/kamailio#4457)
### Description
For now, `htable` exporting `table_spec` and `init_tables`. [Link](https://github.com/kamailio/kamailio/blob/18beef305002e6b2a4a6504273a33db3aa...)
When spec contains `dbmode=1`, then data is not loaded from the database, and `htable` cache data is not available after Kamailio restart.
It would be fine to expose `ht_db_load_tables` via `htable` API and other Kamailio modules can get cache after Kamailio restart.
### Expected behavior htables defined via API with param dbmode=1 loaded after Kamailio restart.
#### Actual observed behavior htables cache is not loaded after Kamailio restart if the table is created via API.
### Possible Solutions
Probably it can be done using this change ```diff From 72e1aea56efa16ecd50806baa94a5cc0f62d37d6 Mon Sep 17 00:00:00 2001 From: Nikolay Ivanuschak ivanuschak.nikolay@gmail.com Date: Wed, 29 Oct 2025 22:57:49 +0300 Subject: [PATCH] htable: added db API functions
--- src/modules/htable/api.c | 25 +++++++++++++++++++++++++ src/modules/htable/api.h | 9 +++++++++ 2 files changed, 34 insertions(+)
diff --git a/src/modules/htable/api.c b/src/modules/htable/api.c index 94095d3d5d..02b299d8c4 100644 --- a/src/modules/htable/api.c +++ b/src/modules/htable/api.c @@ -26,6 +26,7 @@ #include "../../core/dprint.h"
#include "ht_api.h" +#include "ht_db.h" #include "api.h" #include "ht_dmq.h"
@@ -157,6 +158,26 @@ int ht_api_init_tables(void) return ht_init_tables(); }
+int ht_api_db_open_con(void) +{ + return ht_db_open_con(); +} + +int ht_api_db_close_con(void) +{ + return ht_db_close_con(); +} + +int ht_api_db_load_tables(void) +{ + return ht_db_load_tables(); +} + +int ht_api_db_sync_tables(void) +{ + return ht_db_sync_tables(); +} + /** * */ @@ -175,5 +196,9 @@ int bind_htable(htable_api_t *api) api->get_expire = ht_api_get_cell_expire; api->rm_re = ht_api_rm_cell_re; api->count_re = ht_api_count_cells_re; + api->db_open_con = ht_api_db_open_con; + api->db_close_con = ht_api_db_close_con; + api->db_load_tables = ht_api_db_load_tables; + api->db_sync_tables = ht_api_db_sync_tables; return 0; } diff --git a/src/modules/htable/api.h b/src/modules/htable/api.h index 2e84f2e0da..1f0a547434 100644 --- a/src/modules/htable/api.h +++ b/src/modules/htable/api.h @@ -38,6 +38,11 @@ typedef int (*ht_api_set_cell_expire_f)( typedef int (*ht_api_get_cell_expire_f)( str *hname, str *name, unsigned int *val);
+typedef int (*ht_api_db_open_con_f)(void); +typedef int (*ht_api_db_close_con_f)(void); +typedef int (*ht_api_db_load_tables_f)(void); +typedef int (*ht_api_db_sync_tables_f)(void); + typedef int (*ht_api_rm_cell_re_f)(str *hname, str *sre, int mode); typedef int (*ht_api_count_cells_re_f)(str *hname, str *sre, int mode);
@@ -52,6 +57,10 @@ typedef struct htable_api ht_api_get_cell_expire_f get_expire; ht_api_rm_cell_re_f rm_re; ht_api_count_cells_re_f count_re; + ht_api_db_open_con_f db_open_con; + ht_api_db_close_con_f db_close_con; + ht_api_db_load_tables_f db_load_tables; + ht_api_db_sync_tables_f db_sync_tables; } htable_api_t;
typedef int (*bind_htable_f)(htable_api_t *api);
miconda left a comment (kamailio/kamailio#4457)
Added, but without the new wrappers, as they were only calling the existing functions.
Closed #4457 as completed.