Module: sip-router Branch: master Commit: 4178ad7297258ef45fce7d6c9cfd6247bdd37809 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4178ad72...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Mon Feb 22 17:48:45 2010 +0100
tm: _reply cleans up after itself
The _reply() function now cleans possible added reply_lumps before exiting. This allows using it not only from request or failure route.
---
modules/tm/t_reply.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c index 47c9dc4..f37903a 100644 --- a/modules/tm/t_reply.c +++ b/modules/tm/t_reply.c @@ -92,6 +92,8 @@ * 2009-06-01 Pre- and post-script callbacks of branch route are * executed (Miklos) * 2009-12-10 reply route is executed under lock to protect the avps (andrei) + * 2010-02-22 _reply() will cleanup any reply lumps that it might have added + * (andrei) * */
@@ -653,7 +655,9 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg, char * buf, *dset; struct bookmark bm; int dset_len; + struct lump_rpl* rpl_l;
+ rpl_l=0; if (code>=200) set_kr(REQ_RPLD); /* compute the buffer in private memory prior to entering lock; * create to-tag if needed */ @@ -671,12 +675,19 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg, || get_to(p_msg)->tag_value.len==0)) { calc_crc_suffix( p_msg, tm_tag_suffix ); buf = build_res_buf_from_sip_req(code,text, &tm_tag, p_msg, &len, &bm); + if (unlikely(rpl_l)){ + unlink_lump_rpl(p_msg, rpl_l); + free_lump_rpl(rpl_l); + } return _reply_light( trans, buf, len, code, text, tm_tag.s, TOTAG_VALUE_LEN, lock, &bm); } else { buf = build_res_buf_from_sip_req(code,text, 0 /*no to-tag*/, p_msg, &len, &bm); - + if (unlikely(rpl_l)){ + unlink_lump_rpl(p_msg, rpl_l); + free_lump_rpl(rpl_l); + } return _reply_light(trans,buf,len,code,text, 0, 0, /* no to-tag */lock, &bm); }