Module: sip-router
Branch: master
Commit: 95a1194f97e74effbdf557e7fcc5db69c26ea1d7
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=95a1194…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Jul 14 18:13:26 2009 +0200
tm: remove unnecessary locking around prepare_to_cancel()
- prepare_to_cancel() is lockless, doesn't need the reply lock
anymore (_reply_light() and rpc_cancel()).
- _reply_light() minor fix: don't run prepare_to_cancel() if
the reply is not a final reply (might affect latter cancel
generation)
---
modules/tm/t_cancel.c | 4 +---
modules/tm/t_reply.c | 10 +++++-----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/modules/tm/t_cancel.c b/modules/tm/t_cancel.c
index 9fbd98b..52f086b 100644
--- a/modules/tm/t_cancel.c
+++ b/modules/tm/t_cancel.c
@@ -360,9 +360,7 @@ void rpc_cancel(rpc_t* rpc, void* c)
return;
}
/* find the branches that need cancel-ing */
- LOCK_REPLIES(trans);
- prepare_to_cancel(trans, &cancel_bm, 0);
- UNLOCK_REPLIES(trans);
+ prepare_to_cancel(trans, &cancel_bm, 0);
/* tell tm to cancel the call */
DBG("Now calling cancel_uacs\n");
i=cancel_uacs(trans, cancel_bm, 0); /* don't fake 487s,
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 65ccce7..ba06cd1 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -522,9 +522,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int
len,
DBG("DEBUG: _reply_light: response building failed\n");
/* determine if there are some branches to be canceled */
if ( is_invite(trans) ) {
- if (lock) LOCK_REPLIES( trans );
prepare_to_cancel(trans, &cancel_bitmap, 0);
- if (lock) UNLOCK_REPLIES( trans );
}
/* and clean-up, including cancellations, if needed */
goto error;
@@ -532,7 +530,6 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int
len,
cancel_bitmap=0;
if (lock) LOCK_REPLIES( trans );
- if ( is_invite(trans) ) prepare_to_cancel(trans, &cancel_bitmap, 0);
if (trans->uas.status>=200) {
LOG( L_ERR, "ERROR: _reply_light: can't generate %d reply"
" when a final %d was sent out\n", code, trans->uas.status);
@@ -570,8 +567,10 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int
len,
run_trans_callbacks(TMCB_LOCAL_COMPLETED, trans,
0, FAKED_REPLY, code);
cleanup_uac_timers( trans );
- if (is_invite(trans))
+ if (is_invite(trans)){
+ prepare_to_cancel(trans, &cancel_bitmap, 0);
cancel_uacs( trans, cancel_bitmap, F_CANCEL_B_KILL );
+ }
start_final_repl_retr( trans );
}
@@ -618,13 +617,14 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int
len,
return 1;
error3:
+ prepare_to_cancel(trans, &cancel_bitmap, 0);
error2:
if (lock) UNLOCK_REPLIES( trans );
pkg_free ( buf );
error:
/* do UAC cleanup */
cleanup_uac_timers( trans );
- if ( is_invite(trans) )
+ if ( is_invite(trans) && cancel_bitmap )
cancel_uacs( trans, cancel_bitmap, F_CANCEL_B_KILL);
/* we did not succeed -- put the transaction on wait */
put_on_wait(trans);