Module: sip-router
Branch: 3.2
Commit: 5d46e1bb59fb39bd539ace1840d502b14225c924
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=5d46e1b…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Nov 18 09:22:26 2011 +0100
diversion: user anchor_lump2 to insert diversion header
- remove the caching of anchor, is not save across many processes, when
handling diversion in request_route and failure_route
(cherry picked from commit 55615d11ece77074ad779d1ad09361b1fd2b2bad)
---
modules_k/diversion/diversion.c | 17 +++++------------
1 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/modules_k/diversion/diversion.c b/modules_k/diversion/diversion.c
index f9f2436..06f3c43 100644
--- a/modules_k/diversion/diversion.c
+++ b/modules_k/diversion/diversion.c
@@ -104,15 +104,10 @@ static int mod_init(void)
static inline int add_diversion_helper(struct sip_msg* msg, str* s)
{
char *ptr;
+ int is_ref;
- static struct lump* anchor = 0;
- static unsigned int msg_id = 0;
+ struct lump* anchor = 0;
- if (msg_id != msg->id) {
- msg_id = msg->id;
- anchor = 0;
- }
-
if (!msg->diversion && parse_headers(msg, HDR_DIVERSION_F, 0) == -1) {
LM_ERR("header parsing failed\n");
return -1;
@@ -126,12 +121,10 @@ static inline int add_diversion_helper(struct sip_msg* msg, str* s)
ptr = msg->unparsed;
}
+ anchor = anchor_lump2(msg, ptr - msg->buf, 0, 0, &is_ref);
if (!anchor) {
- anchor = anchor_lump(msg, ptr - msg->buf, 0, 0);
- if (!anchor) {
- LM_ERR("can't get anchor\n");
- return -2;
- }
+ LM_ERR("can't get anchor\n");
+ return -2;
}
if (!insert_new_lump_before(anchor, s->s, s->len, 0)) {