Module: sip-router
Branch: master
Commit: 5194b4c7776d24b88be51f799e67af7ddaf3da1a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5194b4c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sun Apr 29 15:33:18 2012 +0200
dialog(k): propagate internal flags from context to dlg structure
- moved condition on DLG_STATE_CONFIRMED in request handling, as it is
set for ACK processing - related to keep-alive initialization for dlg
---
modules_k/dialog/dialog.c | 2 +-
modules_k/dialog/dlg_handlers.c | 7 ++++---
modules_k/dialog/dlg_hash.c | 9 ++++++++-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/modules_k/dialog/dialog.c b/modules_k/dialog/dialog.c
index 1691ba7..3a404d1 100644
--- a/modules_k/dialog/dialog.c
+++ b/modules_k/dialog/dialog.c
@@ -694,7 +694,7 @@ static int child_init(int rank)
if(rank==PROC_MAIN && dlg_ka_timer>0 && dlg_ka_interval>0)
{
if(fork_sync_timer(PROC_TIMER, "Dialog KA Timer", 1 /*socks flag*/,
- dlg_ka_timer_exec, NULL, dlg_ka_interval /*sec*/)<0) {
+ dlg_ka_timer_exec, NULL, dlg_ka_timer /*sec*/)<0) {
LM_ERR("failed to start ka timer routine as process\n");
return -1; /* error */
}
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index 6f87826..0b528a0 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -476,9 +476,6 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params
*param)
goto done;
}
- if (new_state==DLG_STATE_CONFIRMED && old_state!=DLG_STATE_CONFIRMED)
- dlg_ka_add(dlg);
-
if (new_state==DLG_STATE_CONFIRMED_NA &&
old_state!=DLG_STATE_CONFIRMED_NA && old_state!=DLG_STATE_CONFIRMED ) {
LM_DBG("dialog %p confirmed (ACK pending)\n",dlg);
@@ -853,6 +850,7 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int
run_initial_cbs)
s.len = strlen(s.s);
dlg_set_toroute(dlg, &s);
dlg->sflags |= _dlg_ctx.flags;
+ dlg->iflags |= _dlg_ctx.iflags;
if (dlg_send_bye!=0 || _dlg_ctx.to_bye!=0)
dlg->iflags |= DLG_IFLAG_TIMEOUTBYE;
@@ -1209,6 +1207,9 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void
*param)
}
}
+ if (new_state==DLG_STATE_CONFIRMED && old_state!=DLG_STATE_CONFIRMED)
+ dlg_ka_add(dlg);
+
/* run actions for the transition */
if (event==DLG_EVENT_REQBYE && new_state==DLG_STATE_DELETED &&
old_state!=DLG_STATE_DELETED) {
diff --git a/modules_k/dialog/dlg_hash.c b/modules_k/dialog/dlg_hash.c
index 9405350..e4d4f7c 100644
--- a/modules_k/dialog/dlg_hash.c
+++ b/modules_k/dialog/dlg_hash.c
@@ -150,9 +150,10 @@ int dlg_ka_add(dlg_cell_t *dlg)
if(*dlg_ka_list_tail!=NULL)
(*dlg_ka_list_tail)->next = dka;
if(*dlg_ka_list_head==NULL)
- *dlg_ka_list_tail = dka;
+ *dlg_ka_list_head = dka;
*dlg_ka_list_tail = dka;
lock_release(dlg_ka_list_lock);
+ LM_DBG("added dlg[%d,%d] to KA list\n", dlg->h_entry, dlg->h_id);
return 0;
}
@@ -176,6 +177,12 @@ int dlg_ka_run(ticks_t ti)
return 0;
}
dka = *dlg_ka_list_head;
+#if 0
+ LM_DBG("dlg ka timer at %lu for"
+ " dlg[%u,%u] on %lu\n", (unsigned long)ti,
+ dka->iuid.h_entry, dka->iuid.h_id,
+ (unsigned long)dka->katime);
+#endif
if(dka->katime>ti) {
lock_release(dlg_ka_list_lock);
return 0;