Module: kamailio
Branch: master
Commit: 0f2f76115a058161061345477ee55126d7e43420
URL:
https://github.com/kamailio/kamailio/commit/0f2f76115a058161061345477ee5512…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-04-06T09:21:02+02:00
dialog: added dlg_db_load_extra() function
- load dialogs from database that are not yet in memory of current
kamailio instance
---
Modified: src/modules/dialog/dialog.c
Modified: src/modules/dialog/dlg_db_handler.c
---
Diff:
https://github.com/kamailio/kamailio/commit/0f2f76115a058161061345477ee5512…
Patch:
https://github.com/kamailio/kamailio/commit/0f2f76115a058161061345477ee5512…
---
diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c
index a7b95bbd32..1689fc9d2b 100644
--- a/src/modules/dialog/dialog.c
+++ b/src/modules/dialog/dialog.c
@@ -192,6 +192,7 @@ static int w_dlg_get(struct sip_msg*, char*, char*, char*);
static int w_is_known_dlg(struct sip_msg *);
static int w_dlg_set_ruri(sip_msg_t *, char *, char *);
static int w_dlg_db_load_callid(sip_msg_t *msg, char *ci, char *p2);
+static int w_dlg_db_load_extra(sip_msg_t *msg, char *p1, char *p2);
static int w_dlg_remote_profile(sip_msg_t *msg, char *cmd, char *pname,
char *pval, char *puid, char *expires);
@@ -250,6 +251,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"dlg_db_load_callid", (cmd_function)w_dlg_db_load_callid, 1,
fixup_spve_null,
0, ANY_ROUTE },
+ {"dlg_db_load_extra", (cmd_function)w_dlg_db_load_extra, 0, 0,
+ 0, ANY_ROUTE },
{"load_dlg", (cmd_function)load_dlg, 0, 0, 0, 0},
{0,0,0,0,0,0}
@@ -1837,6 +1840,27 @@ static int w_dlg_db_load_callid(sip_msg_t *msg, char *ci, char
*p2)
return ki_dlg_db_load_callid(msg, &sc);
}
+/**
+ *
+ */
+static int ki_dlg_db_load_extra(sip_msg_t *msg)
+{
+ int ret;
+
+ ret = load_dialog_info_from_db(dlg_hash_size, db_fetch_rows, 2, NULL);
+
+ if(ret==0) return 1;
+ return ret;
+}
+
+/**
+ *
+ */
+static int w_dlg_db_load_extra(sip_msg_t *msg, char *p1, char *p2)
+{
+ return ki_dlg_db_load_extra(msg);
+}
+
/**
*
*/
@@ -1937,6 +1961,11 @@ static sr_kemi_t sr_kemi_dialog_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("dialog"), str_init("dlg_db_load_extra"),
+ SR_KEMIP_INT, ki_dlg_db_load_extra,
+ { SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
};
diff --git a/src/modules/dialog/dlg_db_handler.c b/src/modules/dialog/dlg_db_handler.c
index a81a72dc97..2a3e4301ad 100644
--- a/src/modules/dialog/dlg_db_handler.c
+++ b/src/modules/dialog/dlg_db_handler.c
@@ -374,8 +374,13 @@ int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows,
dit = dit->next;
}
if(dit) {
- LM_WARN("conflicting dialog id: %u/%u - skipping\n",
+ if(mode==1) {
+ LM_WARN("conflicting dialog id: %u/%u - skipping\n",
dlg->h_entry, (unsigned int)VAL_INT(values+1));
+ } else {
+ LM_DBG("conflicting dialog id: %u/%u - skipping\n",
+ dlg->h_entry, (unsigned int)VAL_INT(values+1));
+ }
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
shm_free(dlg);
continue;
@@ -517,6 +522,23 @@ int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows,
for(i=0; i<loaded_extra; i++) {
load_dialog_vars_from_db(fetch_num_rows, 1, &dbuid[i]);
}
+ if(loaded_extra_more) {
+ /* more dialogs loaded - scan hash table */
+ for(i=0; i<d_table->size; i++) {
+ dlg_lock(d_table, &d_table->entries[i]);
+ dlg = d_table->entries[i].first;
+ while (dlg) {
+ if(dlg->dflags & DLG_FLAG_DB_LOAD_EXTRA) {
+ dbuid[0].h_entry = dlg->h_entry;
+ dbuid[0].h_id = dlg->h_id;
+ load_dialog_vars_from_db(fetch_num_rows, 1, &dbuid[0]);
+ dlg->dflags &= ~DLG_FLAG_DB_LOAD_EXTRA;
+ }
+ dlg = dlg->next;
+ }
+ dlg_unlock(d_table, &d_table->entries[i]);
+ }
+ }
goto end;
}