Browse code

core: support for marking a "consumed" r-uri

The main/message r-uri can now be marked as "consumed" during
forking or as "new".
New function introduced (dset.h): ruri_mark_new(),
ruri_mark_consumed(), ruri_get_forking_state().
rewrite_uri() will now automatically mark the uri as "new".

Andrei Pelinescu-Onciul authored on 27/05/2010 08:51:51
Showing 2 changed files
... ...
@@ -27,11 +27,10 @@
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28 28
  */
29 29
 
30
-/*!
31
- * \file
32
- * \brief SIP-router core :: 
33
- * \ingroup core
34
- * Module: \ref core
30
+/** destination set / branches support.
31
+ * @file dset.c
32
+ * @ingroup core
33
+ * Module: @ref core
35 34
  */
36 35
 
37 36
 #include <string.h>
... ...
@@ -68,6 +67,9 @@ unsigned int nr_branches = 0;
68 68
 /* branch iterator */
69 69
 static int branch_iterator = 0;
70 70
 
71
+/* used to mark ruris "consumed" when branching (1 new, 0 consumed) */
72
+int ruri_is_new = 0;
73
+
71 74
 /* The q parameter of the Request-URI */
72 75
 static qvalue_t ruri_q = Q_UNSPECIFIED;
73 76
 
... ...
@@ -266,6 +268,7 @@ void clear_branches(void)
266 266
 	nr_branches = 0;
267 267
 	ruri_q = Q_UNSPECIFIED;
268 268
 	ruri_bflags = 0;
269
+	ruri_mark_consumed();
269 270
 }
270 271
 
271 272
 
... ...
@@ -493,6 +496,8 @@ int rewrite_uri(struct sip_msg* _m, str* _s)
493 493
 
494 494
         _m->new_uri.s = buf;
495 495
         _m->new_uri.len = _s->len;
496
+        /* mark ruri as new and available for forking */
497
+        ruri_mark_new();
496 498
 
497 499
         return 1;
498 500
 }
... ...
@@ -37,6 +37,7 @@
37 37
 
38 38
 
39 39
 extern unsigned int nr_branches;
40
+extern int ruri_is_new;
40 41
 
41 42
 /*! \brief
42 43
  * Structure for storing branch attributes
... ...
@@ -166,6 +167,15 @@ inline static int get_request_uri(struct sip_msg* _m, str* _u)
166 166
 }
167 167
 
168 168
 
169
+#define ruri_mark_new() (ruri_is_new = 1)
170
+
171
+#define ruri_mark_consumed()  (ruri_is_new = 0)
172
+
173
+/** returns whether or not ruri should be used when forking.
174
+  * (usefull for serial forking)
175
+  * @return 0 if already marked as consumed, 1 if not.
176
+ */
177
+#define ruri_get_forking_state() (ruri_is_new)
169 178
 
170 179
 int rewrite_uri(struct sip_msg* _m, str* _s);
171 180