Module: sip-router
Branch: tmp/tm_async_reply_support
Commit: 749ce7e29901f79597c461c4cd161d3c3e24dda2
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=749ce7e…
Author: Jason Penton <jason.penton(a)smilecoms.com>
Committer: Jason Penton <jason.penton(a)smilecoms.com>
Date: Fri Jul 12 16:14:08 2013 +0200
modules/tm: more async improvements
---
modules/tm/h_table.h | 2 ++
modules/tm/t_fwd.c | 2 ++
modules/tm/t_reply.c | 4 ++--
modules/tm/t_suspend.c | 17 +++++++----------
4 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/modules/tm/h_table.h b/modules/tm/h_table.h
index e4f2fa1..48027c4 100644
--- a/modules/tm/h_table.h
+++ b/modules/tm/h_table.h
@@ -270,6 +270,7 @@ typedef struct async_state
{
unsigned int backup_route;
unsigned int backup_branch;
+ unsigned int blind_uac;
unsigned int ruri_new;
}async_state_type;
@@ -317,6 +318,7 @@ struct totag_elem {
# define T_PASS_PROVISIONAL_FLAG (1<<11)
# define pass_provisional(_t_) ((_t_)->flags&T_PASS_PROVISIONAL_FLAG)
#endif
+#define T_ASYNC_CONTINUE (1<<9) /* Is this transaction in a continuation after
being suspended */
/* unsigned short should be enough for a retr. timer: max. 65535 ms =>
* max retr. = 65 s which should be enough and saves us 2*2 bytes */
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c
index 55d45f4..d4b967d 100644
--- a/modules/tm/t_fwd.c
+++ b/modules/tm/t_fwd.c
@@ -755,6 +755,8 @@ int add_blind_uac( /*struct cell *t*/ )
membar_write(); /* to allow lockless prepare_to_cancel() we want to be sure
all the writes finished before updating branch number*/
t->nr_of_outgoings=(branch+1);
+ t->async_backup.blind_uac = branch;
+
/* start FR timer -- protocol set by default to PROTO_NONE,
which means retransmission timer will not be started
*/
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index c009a18..2a45188 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1379,8 +1379,8 @@ int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int
*res_code)
* to be a pending, incomplete branch. */
if ((!t->uac[b].request.buffer) && (t->uac[b].last_received>=200))
continue;
- /* there is still an unfinished UAC transaction; wait now! */
- if ( t->uac[b].last_received<200 )
+ /* there is still an unfinished UAC transaction (we ignore unfinished blind UACs) wait
now! */
+ if ( t->uac[b].last_received<200 && !((t->flags&T_ASYNC_CONTINUE)
&& b==t->async_backup.blind_uac))
return -2;
/* if reply is null => t_send_branch "faked" reply, skip over it */
if ( rpl &&
diff --git a/modules/tm/t_suspend.c b/modules/tm/t_suspend.c
index 3b03f97..b9c92e6 100644
--- a/modules/tm/t_suspend.c
+++ b/modules/tm/t_suspend.c
@@ -103,7 +103,7 @@ int t_suspend(struct sip_msg *msg,
*hash_index = t->hash_index;
*label = t->label;
- /* add a bling UAC to let the fr timer running */
+ /* add a blind UAC to let the fr timer running */
if (add_blind_uac() < 0) {
LOG(L_ERR, "ERROR: t_suspend: " \
"failed to add the blind UAC\n");
@@ -205,15 +205,12 @@ int t_continue(unsigned int hash_index, unsigned int label,
* form calling t_continue() multiple times simultaneously */
LOCK_ASYNC_CONTINUE(t);
- /* Try to find the blind UAC, and cancel its fr timer.
- * We assume that the last blind uac called t_continue(). */
- for ( branch = t->nr_of_outgoings-1;
- branch >= 0 && t->uac[branch].request.buffer;
- branch--);
-
- if (branch >= 0) {
+ t->flags |= T_ASYNC_CONTINUE; //we can now know anywhere in kamailio that we
are executing post a suspend.
+
+
+ branch = t->async_backup.blind_uac;
+ if (branch >= 0) {
stop_rb_timers(&t->uac[branch].request);
-
if (t->uac[branch].last_received != 0) {
/* Either t_continue() has already been
* called or the branch has already timed out.
@@ -231,7 +228,7 @@ int t_continue(unsigned int hash_index, unsigned int label,
* for example when t_reply() is called from
* a failure route => deadlock, because both
* of them need the reply lock to be held. */
- t->uac[branch].last_received=500;
+ //t->uac[branch].last_received=500; we dont need this anymore, we are not locking
replies
uac = &t->uac[branch];
}
/* else