[sr-dev] git:master:e8cd0ebb: dialog: option to set the limit for failed keepalive to end the dialog

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 4 10:55:52 CEST 2016


Module: kamailio
Branch: master
Commit: e8cd0ebbcc00ef7d5fba4771e9b2c1c5ad1f9a92
URL: https://github.com/kamailio/kamailio/commit/e8cd0ebbcc00ef7d5fba4771e9b2c1c5ad1f9a92

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-04-04T10:55:36+02:00

dialog: option to set the limit for failed keepalive to end the dialog

- new parameter ka_failed_limit, default value is 1

---

Modified: modules/dialog/dialog.c
Modified: modules/dialog/dlg_req_within.c

---

Diff:  https://github.com/kamailio/kamailio/commit/e8cd0ebbcc00ef7d5fba4771e9b2c1c5ad1f9a92.diff
Patch: https://github.com/kamailio/kamailio/commit/e8cd0ebbcc00ef7d5fba4771e9b2c1c5ad1f9a92.patch

---

diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c
index db6c3ff..57d69a0 100644
--- a/modules/dialog/dialog.c
+++ b/modules/dialog/dialog.c
@@ -104,6 +104,7 @@ int initial_cbs_inscript = 1;
 int dlg_wait_ack = 1;
 static int dlg_timer_procs = 0;
 static int _dlg_track_cseq_updates = 0;
+int dlg_ka_failed_limit = 1;
 
 int dlg_event_rt[DLG_EVENTRT_MAX];
 
@@ -221,10 +222,10 @@ static cmd_export_t cmds[]={
 			0, ANY_ROUTE },
 	{"dlg_set_timeout", (cmd_function)w_dlg_set_timeout,  3,fixup_igp_all,
 			0, ANY_ROUTE },
-	{"dlg_set_timeout_by_profile", 
+	{"dlg_set_timeout_by_profile",
 		(cmd_function) w_dlg_set_timeout_by_profile2, 2, fixup_profile,
 			0, ANY_ROUTE },
-	{"dlg_set_timeout_by_profile", 
+	{"dlg_set_timeout_by_profile",
 		(cmd_function) w_dlg_set_timeout_by_profile3, 3, fixup_profile,
 			0, ANY_ROUTE },
 	{"dlg_set_property", (cmd_function)w_dlg_set_property,1,fixup_spve_null,
@@ -293,6 +294,7 @@ static param_export_t mod_params[]={
 	{ "track_cseq_updates",    PARAM_INT, &_dlg_track_cseq_updates  },
 	{ "lreq_callee_headers",   PARAM_STR, &dlg_lreq_callee_headers  },
 	{ "db_skip_load",          INT_PARAM, &db_skip_load             },
+	{ "ka_failed_limit",       INT_PARAM, &dlg_ka_failed_limit      },
 	{ 0,0,0 }
 };
 
diff --git a/modules/dialog/dlg_req_within.c b/modules/dialog/dlg_req_within.c
index c20e676..8279171 100644
--- a/modules/dialog/dlg_req_within.c
+++ b/modules/dialog/dlg_req_within.c
@@ -53,8 +53,11 @@
 
 extern str dlg_extra_hdrs;
 extern str dlg_lreq_callee_headers;
+extern int dlg_ka_failed_limit;
 
-
+/**
+ *
+ */
 int free_tm_dlg(dlg_t *td)
 {
 	if(td)
@@ -241,7 +244,7 @@ void bye_reply_cb(struct cell* t, int type, struct tmcb_params* ps){
 /* callback function to handle responses to the keep-alive request */
 void dlg_ka_cb_all(struct cell* t, int type, struct tmcb_params* ps, int dir)
 {
-
+	int tend;
 	dlg_cell_t* dlg;
 	dlg_iuid_t *iuid = NULL;
 
@@ -269,12 +272,26 @@ void dlg_ka_cb_all(struct cell* t, int type, struct tmcb_params* ps, int dir)
 			LM_DBG("skip updating non-confirmed dialogs\n");
 			goto done;
 		}
-		if(update_dlg_timer(&dlg->tl, 10)<0) {
-			LM_ERR("failed to update dialog lifetime\n");
-			goto done;
+		tend = 0;
+		if(dir==DLG_CALLER_LEG) {
+			dlg->ka_src_counter++;
+			if(dlg->ka_src_counter>=dlg_ka_failed_limit) {
+				tend = 1;
+			}
+		} else {
+			dlg->ka_dst_counter++;
+			if(dlg->ka_dst_counter>=dlg_ka_failed_limit) {
+				tend = 1;
+			}
+		}
+		if(tend) {
+			if(update_dlg_timer(&dlg->tl, 10)<0) {
+				LM_ERR("failed to update dialog lifetime\n");
+				goto done;
+			}
+			dlg->lifetime = 10;
+			dlg->dflags |= DLG_FLAG_CHANGED;
 		}
-		dlg->lifetime = 10;
-		dlg->dflags |= DLG_FLAG_CHANGED;
 	}
 
 done:




More information about the sr-dev mailing list