Преглед изворни кода

- added support for lump_rpl in failur route

Bogdan-Andrei Iancu пре 22 година
родитељ
комит
36a1abc014
4 измењених фајлова са 29 додато и 10 уклоњено
  1. 16 3
      data_lump_rpl.c
  2. 3 0
      data_lump_rpl.h
  3. 2 2
      modules/tm/sip_msg.c
  4. 8 5
      modules/tm/t_reply.c

+ 16 - 3
data_lump_rpl.c

@@ -47,8 +47,8 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
 
 	/* some checkings */
 	if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY)
-	|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0) {
-		LOG(L_ERR,"ERROR:add_lump_rpl: bad type flags (none or both)!\n");
+	|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) {
+		LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags);
 		goto error;
 	}
 	if (len<=0 || s==0) {
@@ -101,7 +101,7 @@ error:
 
 
 
-void free_lump_rpl(struct lump_rpl* lump)
+inline void free_lump_rpl(struct lump_rpl* lump)
 {
 	if (lump) {
 		if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP)
@@ -134,3 +134,16 @@ void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
 }
 
 
+
+void del_nonshm_lump_rpl( struct lump_rpl **head_list)
+{
+	struct lump_rpl *foo;
+
+	while( (*head_list) && (((*head_list)->flags&LUMP_RPL_SHMEM)==0) ) {
+		foo = (*head_list);
+		(*head_list) = foo->next;
+		free_lump_rpl( foo );
+	}
+}
+
+

+ 3 - 0
data_lump_rpl.h

@@ -44,6 +44,7 @@
 #define LUMP_RPL_BODY    (1<<2)
 #define LUMP_RPL_NODUP   (1<<3)
 #define LUMP_RPL_NOFREE  (1<<4)
+#define LUMP_RPL_SHMEM   (1<<5)
 
 struct lump_rpl
 {
@@ -58,4 +59,6 @@ void free_lump_rpl(struct lump_rpl* );
 
 void unlink_lump_rpl(struct sip_msg *, struct lump_rpl* );
 
+void del_nonshm_lump_rpl(  struct lump_rpl ** );
+
 #endif

+ 2 - 2
modules/tm/sip_msg.c

@@ -679,8 +679,8 @@ do { \
 	{
 		*(rpl_lump_anchor)=(struct lump_rpl*)p;
 		p+=ROUND4(sizeof( struct lump_rpl ));
-		(*rpl_lump_anchor)->flags =
-			rpl_lump->flags&(~(LUMP_RPL_NODUP|LUMP_RPL_NOFREE));
+		(*rpl_lump_anchor)->flags = LUMP_RPL_SHMEM |
+			(rpl_lump->flags&(~(LUMP_RPL_NODUP|LUMP_RPL_NOFREE)));
 		(*rpl_lump_anchor)->text.len = rpl_lump->text.len;
 		(*rpl_lump_anchor)->text.s=p;
 		p+=ROUND4(rpl_lump->text.len);

+ 8 - 5
modules/tm/t_reply.c

@@ -494,11 +494,11 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		run_trans_callbacks( TMCB_ON_FAILURE, t, &fake_req, rpl, code);
 	}
 	if (t->on_negative) {
-	/* avoid recursion -- if failure_route forwards, and does not 
-	 * set next failure route, failure_route will not be rentered
-	 * on failure */
-	t_on_negative(0);
-	/* run a reply_route action if some was marked */
+		/* avoid recursion -- if failure_route forwards, and does not 
+		 * set next failure route, failure_route will not be rentered
+		 * on failure */
+		t_on_negative(0);
+		/* run a reply_route action if some was marked */
 		if (run_actions(failure_rlist[t->on_negative], &fake_req)<0)
 			LOG(L_ERR, "ERROR: run_failure_handlers: Error in do_action\n");
 	}
@@ -512,6 +512,9 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		pkg_free(fake_req.new_uri.s);
 		fake_req.new_uri.s = 0;
 	}
+	del_nonshm_lump_rpl( &(fake_req.reply_lump) );
+	/* if failure handler changed flag, update transaction context */
+	shmem_msg->flags = fake_req.flags;
 
 	return 1;
 }