Browse code

- added support for lump_rpl in failur route

Bogdan-Andrei Iancu authored on 18/12/2003 22:45:23
Showing 4 changed files
... ...
@@ -47,8 +47,8 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
47 47
 
48 48
 	/* some checkings */
49 49
 	if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY)
50
-	|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0) {
51
-		LOG(L_ERR,"ERROR:add_lump_rpl: bad type flags (none or both)!\n");
50
+	|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) {
51
+		LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags);
52 52
 		goto error;
53 53
 	}
54 54
 	if (len<=0 || s==0) {
... ...
@@ -101,7 +101,7 @@ error:
101 101
 
102 102
 
103 103
 
104
-void free_lump_rpl(struct lump_rpl* lump)
104
+inline void free_lump_rpl(struct lump_rpl* lump)
105 105
 {
106 106
 	if (lump) {
107 107
 		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)
134 134
 }
135 135
 
136 136
 
137
+
138
+void del_nonshm_lump_rpl( struct lump_rpl **head_list)
139
+{
140
+	struct lump_rpl *foo;
141
+
142
+	while( (*head_list) && (((*head_list)->flags&LUMP_RPL_SHMEM)==0) ) {
143
+		foo = (*head_list);
144
+		(*head_list) = foo->next;
145
+		free_lump_rpl( foo );
146
+	}
147
+}
148
+
149
+
... ...
@@ -44,6 +44,7 @@
44 44
 #define LUMP_RPL_BODY    (1<<2)
45 45
 #define LUMP_RPL_NODUP   (1<<3)
46 46
 #define LUMP_RPL_NOFREE  (1<<4)
47
+#define LUMP_RPL_SHMEM   (1<<5)
47 48
 
48 49
 struct lump_rpl
49 50
 {
... ...
@@ -58,4 +59,6 @@ void free_lump_rpl(struct lump_rpl* );
58 58
 
59 59
 void unlink_lump_rpl(struct sip_msg *, struct lump_rpl* );
60 60
 
61
+void del_nonshm_lump_rpl(  struct lump_rpl ** );
62
+
61 63
 #endif
... ...
@@ -679,8 +679,8 @@ do { \
679 679
 	{
680 680
 		*(rpl_lump_anchor)=(struct lump_rpl*)p;
681 681
 		p+=ROUND4(sizeof( struct lump_rpl ));
682
-		(*rpl_lump_anchor)->flags =
683
-			rpl_lump->flags&(~(LUMP_RPL_NODUP|LUMP_RPL_NOFREE));
682
+		(*rpl_lump_anchor)->flags = LUMP_RPL_SHMEM |
683
+			(rpl_lump->flags&(~(LUMP_RPL_NODUP|LUMP_RPL_NOFREE)));
684 684
 		(*rpl_lump_anchor)->text.len = rpl_lump->text.len;
685 685
 		(*rpl_lump_anchor)->text.s=p;
686 686
 		p+=ROUND4(rpl_lump->text.len);
... ...
@@ -494,11 +494,11 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
494 494
 		run_trans_callbacks( TMCB_ON_FAILURE, t, &fake_req, rpl, code);
495 495
 	}
496 496
 	if (t->on_negative) {
497
-	/* avoid recursion -- if failure_route forwards, and does not 
498
-	 * set next failure route, failure_route will not be rentered
499
-	 * on failure */
500
-	t_on_negative(0);
501
-	/* run a reply_route action if some was marked */
497
+		/* avoid recursion -- if failure_route forwards, and does not 
498
+		 * set next failure route, failure_route will not be rentered
499
+		 * on failure */
500
+		t_on_negative(0);
501
+		/* run a reply_route action if some was marked */
502 502
 		if (run_actions(failure_rlist[t->on_negative], &fake_req)<0)
503 503
 			LOG(L_ERR, "ERROR: run_failure_handlers: Error in do_action\n");
504 504
 	}
... ...
@@ -512,6 +512,9 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
512 512
 		pkg_free(fake_req.new_uri.s);
513 513
 		fake_req.new_uri.s = 0;
514 514
 	}
515
+	del_nonshm_lump_rpl( &(fake_req.reply_lump) );
516
+	/* if failure handler changed flag, update transaction context */
517
+	shmem_msg->flags = fake_req.flags;
515 518
 
516 519
 	return 1;
517 520
 }