From 897e775a6353ab1e4738ad3b0c3d1c1e53980277 Mon Sep 17 00:00:00 2001 From: Phil Lavin Date: Fri, 19 Feb 2016 12:01:27 +0000 Subject: [PATCH 1/2] pua_dialoginfo: support for sending "Trying" state for callee - Implement callee_trying parameter in pua_dialoginfo which causes a "Trying" state to be sent for both the caller and callee when a new dialog is created. --- modules/pua_dialoginfo/doc/pua_dialoginfo.xml | 7 +++++++ .../doc/pua_dialoginfo_admin.xml | 18 ++++++++++++++++++ modules/pua_dialoginfo/pua_dialoginfo.c | 11 +++++++++++ 3 files changed, 36 insertions(+) diff --git a/modules/pua_dialoginfo/doc/pua_dialoginfo.xml b/modules/pua_dialoginfo/doc/pua_dialoginfo.xml index f4d7a0d0f60..b3001de25b9 100644 --- a/modules/pua_dialoginfo/doc/pua_dialoginfo.xml +++ b/modules/pua_dialoginfo/doc/pua_dialoginfo.xml @@ -38,6 +38,13 @@ Darilion IPCom + + Phil + Lavin +
+ phil.lavin@synety.com +
+
2006 diff --git a/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml b/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml index e08402d0463..505378c4428 100644 --- a/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml +++ b/modules/pua_dialoginfo/doc/pua_dialoginfo_admin.xml @@ -461,6 +461,24 @@ modparam("pua_dialoginfo", "pubruri_callee_dlg_var", "pubruri_callee") +
+ <varname>callee_trying</varname> (int) + + If this parameter is set, a "Trying" state will be sent for both the + caller and callee, rather than just the caller. + + + Default value is 0. + + + Set <varname>callee_trying</varname> parameter + +... +modparam("pua_dialoginfo", "callee_trying", 1) +... + + +
diff --git a/modules/pua_dialoginfo/pua_dialoginfo.c b/modules/pua_dialoginfo/pua_dialoginfo.c index 446d980f05e..2e050d38b5b 100644 --- a/modules/pua_dialoginfo/pua_dialoginfo.c +++ b/modules/pua_dialoginfo/pua_dialoginfo.c @@ -63,6 +63,7 @@ MODULE_VERSION #define DEF_USE_PUBRURI_AVPS 0 #define DEF_PUBRURI_CALLER_AVP 0 #define DEF_PUBRURI_CALLEE_AVP 0 +#define DEF_CALLEE_TRYING 0 /* define PUA_DIALOGINFO_DEBUG to activate more verbose @@ -91,6 +92,7 @@ int caller_confirmed = DEF_CALLER_ALWAYS_CONFIRMED; int include_req_uri = DEF_INCLUDE_REQ_URI; int send_publish_flag = DEF_SEND_PUBLISH_FLAG; int use_pubruri_avps = DEF_USE_PUBRURI_AVPS; +int callee_trying = DEF_CALLEE_TRYING; char * pubruri_caller_avp = DEF_PUBRURI_CALLER_AVP; char * pubruri_callee_avp = DEF_PUBRURI_CALLEE_AVP; @@ -119,6 +121,7 @@ static param_export_t params[]={ {"pubruri_callee_avp", PARAM_STRING, &pubruri_callee_avp }, {"pubruri_caller_dlg_var", PARAM_STR, &caller_dlg_var }, {"pubruri_callee_dlg_var", PARAM_STR, &callee_dlg_var }, + {"callee_trying", INT_PARAM, &callee_trying }, {0, 0, 0 } }; @@ -599,6 +602,14 @@ __dialog_created(struct dlg_cell *dlg, int type, struct dlg_cb_params *_params) &(dlg->callid), 1, dlginfo->lifetime, 0, 0, 0, 0, (send_publish_flag==-1)?1:0); + if (callee_trying) + { + dialog_publish_multi("Trying", dlginfo->pubruris_callee, + (include_req_uri)?&(dlg->req_uri):&(dlg->to_uri), + &(dlg->from_uri), + &(dlg->callid), 0, dlginfo->lifetime, + 0, 0, 0, 0, (send_publish_flag==-1)?1:0); + } } static void From 1c0242fecb1a5ea9a3fde54b8ce331886e564d39 Mon Sep 17 00:00:00 2001 From: Phil Lavin Date: Fri, 19 Feb 2016 12:03:40 +0000 Subject: [PATCH 2/2] presence: Fully implement table locking for updating the presentity table - Implement table locking for all routes through update_presentity in order to avoid a number of different race conditions which resulted in extraneous data being put into the presentity table. --- modules/presence/presentity.c | 50 +++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/modules/presence/presentity.c b/modules/presence/presentity.c index 0f3c3e5712f..1c385b53e0a 100644 --- a/modules/presence/presentity.c +++ b/modules/presence/presentity.c @@ -426,6 +426,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, goto error; } + if (pa_dbf.start_transaction) + { + if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0) + { + LM_ERR("in start_transaction\n"); + goto error; + } + } + LM_DBG("inserting %d cols into table\n",n_query_cols); if (pa_dbf.insert(pa_db, query_cols, query_vals, n_query_cols) < 0) @@ -468,22 +477,8 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if (pa_dbf.replace(pa_db, query_cols, query_vals, n_query_cols, 4, 0) < 0) { LM_ERR("replacing record in database\n"); - if (pa_dbf.abort_transaction) - { - if (pa_dbf.abort_transaction(pa_db) < 0) - LM_ERR("in abort_transaction\n"); - } goto error; } - - if (pa_dbf.end_transaction) - { - if (pa_dbf.end_transaction(pa_db) < 0) - { - LM_ERR("in end_transaction\n"); - goto error; - } - } } if( publ_send200ok(msg, presentity->expires, presentity->etag)< 0) @@ -503,6 +498,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, goto error; } + if (pa_dbf.start_transaction) + { + if (pa_dbf.start_transaction(pa_db, db_table_lock) < 0) + { + LM_ERR("in start_transaction\n"); + goto error; + } + } + if(EVENT_DIALOG_SLA(presentity->event->evp)) { @@ -837,6 +841,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if(pres_uri.s) pkg_free(pres_uri.s); + if (pa_dbf.end_transaction) + { + if (pa_dbf.end_transaction(pa_db) < 0) + { + LM_ERR("in end_transaction\n"); + goto error; + } + } + return 0; send_412: @@ -867,6 +880,15 @@ int update_presentity(struct sip_msg* msg, presentity_t* presentity, str* body, if(pres_uri.s) pkg_free(pres_uri.s); + if (pa_dbf.abort_transaction) + { + if (pa_dbf.abort_transaction(pa_db) < 0) + { + LM_ERR("in abort_transaction\n"); + goto error; + } + } + return ret; }