2
0
Эх сурвалжийг харах

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 15 жил өмнө
parent
commit
b4ea439353
2 өөрчлөгдсөн 20 нэмэгдсэн , 5 устгасан
  1. 10 5
      dset.c
  2. 10 0
      dset.h

+ 10 - 5
dset.c

@@ -27,11 +27,10 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*!
- * \file
- * \brief SIP-router core :: 
- * \ingroup core
- * Module: \ref core
+/** destination set / branches support.
+ * @file dset.c
+ * @ingroup core
+ * Module: @ref core
  */
 
 #include <string.h>
@@ -68,6 +67,9 @@ unsigned int nr_branches = 0;
 /* branch iterator */
 static int branch_iterator = 0;
 
+/* used to mark ruris "consumed" when branching (1 new, 0 consumed) */
+int ruri_is_new = 0;
+
 /* The q parameter of the Request-URI */
 static qvalue_t ruri_q = Q_UNSPECIFIED;
 
@@ -266,6 +268,7 @@ void clear_branches(void)
 	nr_branches = 0;
 	ruri_q = Q_UNSPECIFIED;
 	ruri_bflags = 0;
+	ruri_mark_consumed();
 }
 
 
@@ -493,6 +496,8 @@ int rewrite_uri(struct sip_msg* _m, str* _s)
 
         _m->new_uri.s = buf;
         _m->new_uri.len = _s->len;
+        /* mark ruri as new and available for forking */
+        ruri_mark_new();
 
         return 1;
 }

+ 10 - 0
dset.h

@@ -37,6 +37,7 @@
 
 
 extern unsigned int nr_branches;
+extern int ruri_is_new;
 
 /*! \brief
  * Structure for storing branch attributes
@@ -166,6 +167,15 @@ inline static int get_request_uri(struct sip_msg* _m, str* _u)
 }
 
 
+#define ruri_mark_new() (ruri_is_new = 1)
+
+#define ruri_mark_consumed()  (ruri_is_new = 0)
+
+/** returns whether or not ruri should be used when forking.
+  * (usefull for serial forking)
+  * @return 0 if already marked as consumed, 1 if not.
+ */
+#define ruri_get_forking_state() (ruri_is_new)
 
 int rewrite_uri(struct sip_msg* _m, str* _s);