Module: sip-router Branch: master Commit: 22f9bd6620b851848853befc677ce6b6b318c483 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=22f9bd66...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Thu Jun 11 20:25:47 2009 +0200
tm: t_check_trans ends script on neg. or local ACK
- t_check_trans will now end the script if the message is an ACK to an existing transaction ended with a negative reply or an ACK to a local transaction (as opposed to a normal proxied one). Before ending the script it will process the ACK in the same way t_newtran would, including calling the appropriate callbacks. t_check_trans behaviour for other requests (e.g. retransmissions, cancels, e2e ACK) remains unchanged.
- added missing callbacks for the retransmitted request case.
Reported-and-tested-by: Juha Heinanen jh at tutpro com.
---
modules/tm/tm.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/modules/tm/tm.c b/modules/tm/tm.c index 982681a..e769b75 100644 --- a/modules/tm/tm.c +++ b/modules/tm/tm.c @@ -1742,8 +1742,9 @@ int w_t_reply_wrp(struct sip_msg *m, unsigned int code, char *txt)
/** script function, check if a msg is assoc. to a transaction. - * @return -1 (not), 1 (reply, ack or cancel for an existing transaction), - * 0 (request retransmission) + * @return -1 (not), 1 (reply, e2e ack or cancel for an existing transaction), + * 0 (request retransmission, ack to negative reply or ack to local + * transaction) * Note: the e2e ack matching works only for local e2e acks or for * transactions with E2EACK* callbacks installed (but even in this * case matching E2EACKs on proxied transaction is not entirely @@ -1763,15 +1764,26 @@ static int t_check_trans(struct sip_msg* msg, char* foo, char* bar) case -2: /* possible e2e ack */ return 1; case 1: /* found */ - if (msg->REQ_METHOD==METHOD_ACK) - /* ack to neg. reply */ - return 1; - /* else retransmission */ t=get_t(); - t_retransmit_reply(t); - UNREF(t); - set_t(0); - return 0; + if (msg->REQ_METHOD==METHOD_ACK){ + /* ack to neg. reply or ack to local trans. + => process it and end the script */ + /* FIXME: there's no way to distinguish here + between acks to local trans. and neg. acks */ + if (unlikely(has_tran_tmcbs(t, TMCB_ACK_NEG_IN))) + run_trans_callbacks(TMCB_ACK_NEG_IN, t, msg, + 0, msg->REQ_METHOD); + t_release_transaction(t); + } else { + /* is a retransmission */ + if (unlikely(has_tran_tmcbs(t, TMCB_REQ_RETR_IN))) + run_trans_callbacks(TMCB_REQ_RETR_IN, t, msg, + 0, msg->REQ_METHOD); + t_retransmit_reply(t); + } + /* no need for UNREF(t); set_t(0) - the end-of-script + t_unref callback will take care of them */ + return 0; /* return from the script */ } /* not found or error */ }