Procházet zdrojové kódy

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
Daniel-Constantin Mierla před 14 roky
rodič
revize
55615d11ec
1 změnil soubory, kde provedl 5 přidání a 12 odebrání
  1. 5 12
      modules_k/diversion/diversion.c

+ 5 - 12
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)) {