[sr-dev] git:treimann/tm-extend-pend-cbs-on-reqin: tm: Consider callbacks registered during execution of a TMCB_REQUEST_IN
Timo Reimann
timo.reimann at 1und1.de
Thu Oct 13 01:34:50 CEST 2011
Module: sip-router
Branch: treimann/tm-extend-pend-cbs-on-reqin
Commit: bc17e80a81e1d791ddb20a8b1e8fb0bb3adffc66
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bc17e80a81e1d791ddb20a8b1e8fb0bb3adffc66
Author: Timo Reimann <timo.reimann at 1und1.de>
Committer: Timo Reimann <timo.reimann at 1und1.de>
Date: Thu Oct 13 01:17:58 2011 +0200
tm: Consider callbacks registered during execution of a TMCB_REQUEST_IN
callback.
---
modules/tm/h_table.c | 5 +++++
modules/tm/t_hooks.c | 21 +++++++++++++++++++++
modules/tm/t_hooks.h | 2 ++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index 18b0857..e6927f5 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -366,6 +366,11 @@ struct cell* build_cell( struct sip_msg* p_msg )
set_early_tmcb_list(p_msg, new_cell);
if(has_reqin_tmcbs())
run_reqin_callbacks( new_cell, p_msg, p_msg->REQ_METHOD);
+
+ /* if new pending callbacks were issued by any TMCB_REQUEST_IN
+ * callback, move them to the transaction as well (possibly
+ * extending the existing list of callbacks) */
+ extend_early_cbs(p_msg->id, new_cell);
}
if (p_msg) {
diff --git a/modules/tm/t_hooks.c b/modules/tm/t_hooks.c
index 8dc77b1..88b862d 100644
--- a/modules/tm/t_hooks.c
+++ b/modules/tm/t_hooks.c
@@ -88,6 +88,27 @@ void set_early_tmcb_list(struct sip_msg *msg, struct cell *t)
}
}
+static void extend_cb_list(struct tmcb_head_list *existing, struct tmcb_head_list *new)
+{
+ struct tm_callback *cbp;
+
+ if (existing->first == 0)
+ *existing = *new;
+ else {
+ for (cbp = (struct tm_callback*)new->first; cbp->next != NULL; cbp = cbp->next) ;
+ cbp->next = (struct tm_callback*)existing->first;
+ existing->first = new->first;
+ existing->reg_types |= new->reg_types;
+ }
+}
+
+void extend_early_cbs(int msgid, struct cell *new_cell) {
+ if (tmcb_early_hl.cb_list.first!=0 && msgid==tmcb_early_hl.msgid) {
+ extend_cb_list(&new_cell->tmcb_hl, &tmcb_early_hl.cb_list);
+ tmcb_early_hl.cb_list.first = 0;
+ }
+}
+
int init_tmcb_lists()
{
req_in_tmcb_hl = (struct tmcb_head_list*)shm_malloc
diff --git a/modules/tm/t_hooks.h b/modules/tm/t_hooks.h
index 38ba5d4..b7d763e 100644
--- a/modules/tm/t_hooks.h
+++ b/modules/tm/t_hooks.h
@@ -423,6 +423,8 @@ extern struct tmcb_head_list* local_req_in_tmcb_hl;
void set_early_tmcb_list(struct sip_msg *msg,
struct cell *t);
+void extend_early_cbs(int msgid, struct cell *new_cell);
+
#define has_tran_tmcbs(_T_, _types_) \
( ((_T_)->tmcb_hl.reg_types)&(_types_) )
#define has_reqin_tmcbs() \
More information about the sr-dev
mailing list