Forráskód Böngészése

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

- new parameter ka_failed_limit, default value is 1
Daniel-Constantin Mierla 9 éve
szülő
commit
e8cd0ebbcc
2 módosított fájl, 28 hozzáadás és 9 törlés
  1. 4 2
      modules/dialog/dialog.c
  2. 24 7
      modules/dialog/dlg_req_within.c

+ 4 - 2
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 }
 };
 

+ 24 - 7
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: