Skip to content

Commit

Permalink
dialog: option to set the limit for failed keepalive to end the dialog
Browse files Browse the repository at this point in the history
- new parameter ka_failed_limit, default value is 1
  • Loading branch information
miconda committed Apr 4, 2016
1 parent ad2f899 commit e8cd0eb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
6 changes: 4 additions & 2 deletions modules/dialog/dialog.c
Expand Up @@ -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];

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
};

Expand Down
31 changes: 24 additions & 7 deletions modules/dialog/dlg_req_within.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e8cd0eb

Please sign in to comment.