From e80c2d573b194ff37683421e999811989509d5ab Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Mon, 9 Dec 2024 10:25:21 +0100 Subject: [PATCH] MT#61703 usrloc: avoid shutdown crashes on destroy * remove destroy of internal structures on mod-destroy callback Change-Id: Ice2361535d1a656b8170232a9298f376a33bc11b (cherry picked from commit 0fc97032fcb6bd1315054b645e313caf465a0aa0) --- debian/patches/series | 7 ++++ .../patches/sipwise/dialog-dlg_get_ttag.patch | 6 +-- ...rt-profile_get_size-for-all-profiles.patch | 10 ++--- ...t-synchronize-on-destroy-for-DB_ONLY.patch | 21 ++++++++++ debian/patches/sipwise/usrloc_dbro.patch | 17 ++------ ...stroy-of-internal-structures-on-mod-.patch | 30 +++++++++++++ ...stroy-of-internal-structures-on-mod-.patch | 23 ++++++++++ ...destroy-of-internal-structures-on-mo.patch | 42 +++++++++++++++++++ ...oy-of-internal-structures-on-mod-des.patch | 36 ++++++++++++++++ ...y-of-internal-structures-on-mod-dest.patch | 38 +++++++++++++++++ ...stroy-of-internal-structures-on-mod-.patch | 29 +++++++++++++ 11 files changed, 237 insertions(+), 22 deletions(-) create mode 100644 debian/patches/sipwise/usrloc-don-t-synchronize-on-destroy-for-DB_ONLY.patch create mode 100644 debian/patches/upstream/dialog-remove-destroy-of-internal-structures-on-mod-.patch create mode 100644 debian/patches/upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch create mode 100644 debian/patches/upstream/presence-remove-destroy-of-internal-structures-on-mo.patch create mode 100644 debian/patches/upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch create mode 100644 debian/patches/upstream/tm-remove-destroy-of-internal-structures-on-mod-dest.patch create mode 100644 debian/patches/upstream/usrloc-remove-destroy-of-internal-structures-on-mod-.patch diff --git a/debian/patches/series b/debian/patches/series index 2ed48d573..8acfafc0b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -40,6 +40,12 @@ upstream/permissions_add_register_allow_with_port_check.patch upstream/multipart-sdp.patch upstream/dialog-don-t-complain-if-dst_var-doesn-t-exist.patch upstream/rtpengine-use-to-tag-for-NG-message-when-rtpp-flags.patch +upstream/dialog-remove-destroy-of-internal-structures-on-mod-.patch +upstream/tm-remove-destroy-of-internal-structures-on-mod-dest.patch +upstream/usrloc-remove-destroy-of-internal-structures-on-mod-.patch +upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch +upstream/presence-remove-destroy-of-internal-structures-on-mo.patch +upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch ### relevant for upstream sipwise/dialplan-don-t-stop-loading-rules-on-error.patch sipwise/kamctl-TMPDIR-config.patch @@ -56,6 +62,7 @@ sipwise/pua_dialoginfo-use_uuid.patch sipwise/http_client-add-method-parameter-to-http_connect.patch sipwise/lost-add-method-parameter-to-http_connect-calls.patch sipwise/rtpengine_add_sip_code.patch +sipwise/usrloc-don-t-synchronize-on-destroy-for-DB_ONLY.patch ### active development # ### Don't just put stuff in any order diff --git a/debian/patches/sipwise/dialog-dlg_get_ttag.patch b/debian/patches/sipwise/dialog-dlg_get_ttag.patch index 3d0407fe8..edb38ba23 100644 --- a/debian/patches/sipwise/dialog-dlg_get_ttag.patch +++ b/debian/patches/sipwise/dialog-dlg_get_ttag.patch @@ -9,7 +9,7 @@ Subject: dialog: dlg_get_ttag() 3 files changed, 211 insertions(+) diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c -index a36f047..020e1ef 100644 +index 152fd9c..8e76506 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -54,6 +54,7 @@ @@ -39,7 +39,7 @@ index a36f047..020e1ef 100644 {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 1,fixup_igp_null, 0, ANY_ROUTE }, {"dlg_set_timeout", (cmd_function)w_dlg_set_timeout, 3,fixup_igp_all, -@@ -1981,6 +1987,121 @@ static int fixup_dlg_set_var_free(void **param, int param_no) +@@ -1973,6 +1979,121 @@ static int fixup_dlg_set_var_free(void **param, int param_no) return -1; } @@ -161,7 +161,7 @@ index a36f047..020e1ef 100644 static int ki_dlg_get(sip_msg_t *msg, str *sc, str *sf, str *st) { dlg_cell_t *dlg = NULL; -@@ -2556,6 +2677,11 @@ static sr_kemi_t sr_kemi_dialog_exports[] = { +@@ -2548,6 +2669,11 @@ static sr_kemi_t sr_kemi_dialog_exports[] = { { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } }, diff --git a/debian/patches/sipwise/dialog-support-profile_get_size-for-all-profiles.patch b/debian/patches/sipwise/dialog-support-profile_get_size-for-all-profiles.patch index 0c6089a5c..17d22c6b6 100644 --- a/debian/patches/sipwise/dialog-support-profile_get_size-for-all-profiles.patch +++ b/debian/patches/sipwise/dialog-support-profile_get_size-for-all-profiles.patch @@ -10,10 +10,10 @@ Subject: dialog: support profile_get_size for all profiles 4 files changed, 69 insertions(+) diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c -index 43752da..a36f047 100644 +index 338f7f6..152fd9c 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c -@@ -3026,6 +3026,31 @@ static void internal_rpc_profile_get_size( +@@ -3018,6 +3018,31 @@ static void internal_rpc_profile_get_size( return; } @@ -45,7 +45,7 @@ index 43752da..a36f047 100644 /*! * \brief Helper function that outputs the dialogs belonging to a given profile via the RPC interface * \see rpc_profile_print_dlgs -@@ -3110,6 +3135,8 @@ static const char *rpc_dlg_set_state_doc[3] = { +@@ -3102,6 +3127,8 @@ static const char *rpc_dlg_set_state_doc[3] = { 0}; static const char *rpc_profile_get_size_doc[2] = { "Returns the number of dialogs belonging to a profile", 0}; @@ -54,7 +54,7 @@ index 43752da..a36f047 100644 static const char *rpc_profile_print_dlgs_doc[2] = { "Lists all the dialogs belonging to a profile", 0}; static const char *rpc_dlg_bridge_doc[2] = { -@@ -3326,6 +3353,11 @@ static void rpc_profile_get_size(rpc_t *rpc, void *c) +@@ -3318,6 +3345,11 @@ static void rpc_profile_get_size(rpc_t *rpc, void *c) } return; } @@ -66,7 +66,7 @@ index 43752da..a36f047 100644 static void rpc_profile_print_dlgs(rpc_t *rpc, void *c) { str profile_name = {NULL, 0}; -@@ -3743,6 +3775,8 @@ static rpc_export_t rpc_methods[] = { +@@ -3735,6 +3767,8 @@ static rpc_export_t rpc_methods[] = { {"dlg.end_dlg", rpc_end_dlg_entry_id, rpc_end_dlg_entry_id_doc, 0}, {"dlg.profile_get_size", rpc_profile_get_size, rpc_profile_get_size_doc, 0}, diff --git a/debian/patches/sipwise/usrloc-don-t-synchronize-on-destroy-for-DB_ONLY.patch b/debian/patches/sipwise/usrloc-don-t-synchronize-on-destroy-for-DB_ONLY.patch new file mode 100644 index 000000000..f8cb14d87 --- /dev/null +++ b/debian/patches/sipwise/usrloc-don-t-synchronize-on-destroy-for-DB_ONLY.patch @@ -0,0 +1,21 @@ +From: Victor Seva +Date: Mon, 9 Dec 2024 10:22:05 +0100 +Subject: usrloc: don't synchronize on destroy for DB_ONLY + +--- + src/modules/usrloc/usrloc_mod.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c +index 0093058..0df21d3 100644 +--- a/src/modules/usrloc/usrloc_mod.c ++++ b/src/modules/usrloc/usrloc_mod.c +@@ -620,7 +620,7 @@ static void destroy(void) + { + /* we need to sync DB in order to flush the cache */ + if(ul_dbh) { +- if(synchronize_all_udomains(0, 1) != 0) { ++ if(ul_db_mode != DB_ONLY && synchronize_all_udomains(0, 1) != 0) { + LM_ERR("flushing cache failed\n"); + } + } diff --git a/debian/patches/sipwise/usrloc_dbro.patch b/debian/patches/sipwise/usrloc_dbro.patch index 5f580faef..22fc86fd6 100644 --- a/debian/patches/sipwise/usrloc_dbro.patch +++ b/debian/patches/sipwise/usrloc_dbro.patch @@ -3,12 +3,12 @@ Date: Thu, 26 Mar 2020 10:06:46 +0100 Subject: usrloc_dbro --- - src/modules/usrloc/usrloc_mod.c | 68 ++++++++++++++++++++++++++++++++++++++++- + src/modules/usrloc/usrloc_mod.c | 64 ++++++++++++++++++++++++++++++++++++++++- src/modules/usrloc/usrloc_mod.h | 2 ++ - 2 files changed, 69 insertions(+), 1 deletion(-) + 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c -index b14fe72..cd73d04 100644 +index b14fe72..1443953 100644 --- a/src/modules/usrloc/usrloc_mod.c +++ b/src/modules/usrloc/usrloc_mod.c @@ -200,6 +200,7 @@ str ulattrs_last_mod_col = str_init( @@ -117,17 +117,6 @@ index b14fe72..cd73d04 100644 /* _rank==PROC_SIPINIT is used even when fork is disabled */ if(_rank == ul_load_rank && ul_db_mode != DB_ONLY && ul_db_load) { /* if cache is used, populate domains from DB */ -@@ -564,6 +626,10 @@ static void destroy(void) - ul_dbf.close(ul_dbh); - } - -+ if (ul_dbh_ro) { -+ ul_dbf_ro.close(ul_dbh_ro); -+ } -+ - free_all_udomains(); - - /* free callbacks list */ diff --git a/src/modules/usrloc/usrloc_mod.h b/src/modules/usrloc/usrloc_mod.h index 7192c9c..4fe237b 100644 --- a/src/modules/usrloc/usrloc_mod.h diff --git a/debian/patches/upstream/dialog-remove-destroy-of-internal-structures-on-mod-.patch b/debian/patches/upstream/dialog-remove-destroy-of-internal-structures-on-mod-.patch new file mode 100644 index 000000000..82335c1df --- /dev/null +++ b/debian/patches/upstream/dialog-remove-destroy-of-internal-structures-on-mod-.patch @@ -0,0 +1,30 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 11:21:58 +0100 +Subject: dialog: remove destroy of internal structures on mod-destroy + callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/dialog/dialog.c | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c +index 43752da..338f7f6 100644 +--- a/src/modules/dialog/dialog.c ++++ b/src/modules/dialog/dialog.c +@@ -865,14 +865,6 @@ static void mod_destroy(void) + dialog_update_db(0, 0); + destroy_dlg_db(); + } +- dlg_bridge_destroy_hdrs(); +- /* no DB interaction from now on */ +- dlg_db_mode = DB_MODE_NONE; +- destroy_dlg_table(); +- destroy_dlg_timer(); +- destroy_dlg_callbacks(DLGCB_CREATED | DLGCB_LOADED); +- destroy_dlg_handlers(); +- destroy_dlg_profiles(); + } + + diff --git a/debian/patches/upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch b/debian/patches/upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch new file mode 100644 index 000000000..b4244c203 --- /dev/null +++ b/debian/patches/upstream/htable-remove-destroy-of-internal-structures-on-mod-.patch @@ -0,0 +1,23 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 11:41:33 +0100 +Subject: htable: remove destroy of internal structures on mod-destroy + callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/htable/htable.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/src/modules/htable/htable.c b/src/modules/htable/htable.c +index 0fcd280..f98fe97 100644 +--- a/src/modules/htable/htable.c ++++ b/src/modules/htable/htable.c +@@ -341,7 +341,6 @@ static void destroy(void) + } + } + } +- ht_destroy(); + } + + /** diff --git a/debian/patches/upstream/presence-remove-destroy-of-internal-structures-on-mo.patch b/debian/patches/upstream/presence-remove-destroy-of-internal-structures-on-mo.patch new file mode 100644 index 000000000..042e9b079 --- /dev/null +++ b/debian/patches/upstream/presence-remove-destroy-of-internal-structures-on-mo.patch @@ -0,0 +1,42 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 12:04:16 +0100 +Subject: presence: remove destroy of internal structures on mod-destroy + callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/presence/presence.c | 20 -------------------- + 1 file changed, 20 deletions(-) + +diff --git a/src/modules/presence/presence.c b/src/modules/presence/presence.c +index 9315c0d..dae0bf7 100644 +--- a/src/modules/presence/presence.c ++++ b/src/modules/presence/presence.c +@@ -635,26 +635,6 @@ static void destroy(void) + } else + timer_db_update(0, 0); + } +- +- if(subs_htable) { +- destroy_shtable(subs_htable, shtable_size); +- } +- +- if(pres_htable) { +- destroy_phtable(); +- } +- +- if(pa_db && pa_dbf.close) { +- pa_dbf.close(pa_db); +- } +- +- if(pres_notifier_id != NULL) { +- shm_free(pres_notifier_id); +- } +- +- destroy_evlist(); +- +- ps_ptable_destroy(); + } + + static int fixup_presence(void **param, int param_no) diff --git a/debian/patches/upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch b/debian/patches/upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch new file mode 100644 index 000000000..d95c2d2b2 --- /dev/null +++ b/debian/patches/upstream/pua-remove-destroy-of-internal-structures-on-mod-des.patch @@ -0,0 +1,36 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 12:08:14 +0100 +Subject: pua: remove destroy of internal structures on mod-destroy callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/pua/pua.c | 8 -------- + 1 file changed, 8 deletions(-) + +diff --git a/src/modules/pua/pua.c b/src/modules/pua/pua.c +index a53bfd8..d69578c 100644 +--- a/src/modules/pua/pua.c ++++ b/src/modules/pua/pua.c +@@ -296,21 +296,13 @@ static int child_init(int rank) + + static void destroy(void) + { +- if(puacb_list) +- destroy_puacb_list(); +- + /* if dbmode is PUA_DB_ONLY, then HashT will be NULL + * so db_update and destroy_htable won't get called */ + if(pua_db && HashT) + db_update(0, 0); + +- if(HashT) +- destroy_htable(); +- + if(pua_db) + pua_dbf.close(pua_db); +- if(pua_evlist) +- destroy_pua_evlist(); + + return; + } diff --git a/debian/patches/upstream/tm-remove-destroy-of-internal-structures-on-mod-dest.patch b/debian/patches/upstream/tm-remove-destroy-of-internal-structures-on-mod-dest.patch new file mode 100644 index 000000000..be54e36cc --- /dev/null +++ b/debian/patches/upstream/tm-remove-destroy-of-internal-structures-on-mod-dest.patch @@ -0,0 +1,38 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 11:28:34 +0100 +Subject: tm: remove destroy of internal structures on mod-destroy callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/tm/t_funcs.c | 17 ----------------- + 1 file changed, 17 deletions(-) + +diff --git a/src/modules/tm/t_funcs.c b/src/modules/tm/t_funcs.c +index 5515a4a..92a7e79 100644 +--- a/src/modules/tm/t_funcs.c ++++ b/src/modules/tm/t_funcs.c +@@ -87,23 +87,6 @@ int send_pr_buffer(struct retr_buf *rb, void *buf, int len + + void tm_shutdown() + { +- +- LM_DBG("start\n"); +- +-#ifdef USE_DNS_FAILOVER +- if(failover_reply_codes) +- shm_free(failover_reply_codes); +- if(failover_reply_codes_cnt) +- shm_free(failover_reply_codes_cnt); +-#endif +- /* destroy the hash table */ +- LM_DBG("emptying hash table\n"); +- free_hash_table(); +- LM_DBG("removing semaphores\n"); +- lock_cleanup(); +- LM_DBG("destroying tmcb lists\n"); +- destroy_tmcb_lists(); +- free_tm_stats(); + LM_DBG("done\n"); + } + diff --git a/debian/patches/upstream/usrloc-remove-destroy-of-internal-structures-on-mod-.patch b/debian/patches/upstream/usrloc-remove-destroy-of-internal-structures-on-mod-.patch new file mode 100644 index 000000000..4fbe71d56 --- /dev/null +++ b/debian/patches/upstream/usrloc-remove-destroy-of-internal-structures-on-mod-.patch @@ -0,0 +1,29 @@ +From: Daniel-Constantin Mierla +Date: Wed, 20 Nov 2024 11:37:40 +0100 +Subject: usrloc: remove destroy of internal structures on mod-destroy + callback + +- it is safer and faster to be removed at once by core or OS when application + context is destroyed +--- + src/modules/usrloc/usrloc_mod.c | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/src/modules/usrloc/usrloc_mod.c b/src/modules/usrloc/usrloc_mod.c +index 1443953..0093058 100644 +--- a/src/modules/usrloc/usrloc_mod.c ++++ b/src/modules/usrloc/usrloc_mod.c +@@ -623,13 +623,7 @@ static void destroy(void) + if(synchronize_all_udomains(0, 1) != 0) { + LM_ERR("flushing cache failed\n"); + } +- ul_dbf.close(ul_dbh); + } +- +- free_all_udomains(); +- +- /* free callbacks list */ +- destroy_ulcb_list(); + } + + /*! \brief