Browse code

core: distinct core and tm onreply route tests

- added TM_ONREPLY_ROUTE and CORE_ONREPLY_ROUTE to the possible
route types. This allows to distinguish between the main reply
route (executed by the core) and onreply routes executed by tm.
ONREPLY_ROUTE was changed to TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE,
so that is_route_type(ONREPLY_ROUTE) will return true both for
CORE_ONREPLY_ROUTE and TM_ONREPLY_ROUTE.

- onreply_route[0] {} is equivalent with onreply_route{}.

- use different route types when parsing the script for
onreply_route{} (CORE_ONREPLY_ROUTE) and onreply_route[x]{},
where x!=0 (TM_ONREPLY_ROUTE).

Andrei Pelinescu-Onciul authored on 22/02/2010 13:49:37
Showing 3 changed files
... ...
@@ -647,7 +647,7 @@ statement:
647 647
 	| module_stm
648 648
 	| {rt=REQUEST_ROUTE;} route_stm
649 649
 	| {rt=FAILURE_ROUTE;} failure_route_stm
650
-	| {rt=ONREPLY_ROUTE;} onreply_route_stm
650
+	| onreply_route_stm
651 651
 	| {rt=BRANCH_ROUTE;} branch_route_stm
652 652
 	| {rt=ONSEND_ROUTE;}   send_route_stm
653 653
 	| {rt=EVENT_ROUTE;}   event_route_stm
... ...
@@ -1775,35 +1775,46 @@ failure_route_stm:
1775 1775
 	}
1776 1776
 	| ROUTE_FAILURE error { yyerror("invalid failure_route statement"); }
1777 1777
 	;
1778
+
1778 1779
 onreply_route_stm:
1779
-	ROUTE_ONREPLY LBRACE actions RBRACE {
1780
+	ROUTE_ONREPLY LBRACE {rt=CORE_ONREPLY_ROUTE;} actions RBRACE {
1780 1781
 	#ifdef SHM_MEM
1781 1782
 		if (!shm_initialized() && init_shm()<0) {
1782 1783
 			yyerror("Can't initialize shared memory");
1783 1784
 			YYABORT;
1784 1785
 		}
1785 1786
 	#endif /* SHM_MEM */
1786
-		push($3, &onreply_rt.rlist[DEFAULT_RT]);
1787
+		push($4, &onreply_rt.rlist[DEFAULT_RT]);
1787 1788
 	}
1788
-	| ROUTE_ONREPLY LBRACK route_name RBRACK LBRACE actions RBRACE {
1789
+	| ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1790
+	| ROUTE_ONREPLY LBRACK route_name RBRACK 
1791
+		{rt=(*$3=='0' && $3[1]==0)?CORE_ONREPLY_ROUTE:TM_ONREPLY_ROUTE;}
1792
+		LBRACE actions RBRACE {
1789 1793
 	#ifdef SHM_MEM
1790 1794
 		if (!shm_initialized() && init_shm()<0) {
1791 1795
 			yyerror("Can't initialize shared memory");
1792 1796
 			YYABORT;
1793 1797
 		}
1794 1798
 	#endif /* SHM_MEM */
1795
-		i_tmp=route_get(&onreply_rt, $3);
1796
-		if (i_tmp==-1){
1797
-			yyerror("internal error");
1798
-			YYABORT;
1799
-		}
1800
-		if (onreply_rt.rlist[i_tmp]){
1801
-			yyerror("duplicate route");
1802
-			YYABORT;
1799
+		if (*$3=='0' && $3[1]==0){
1800
+			/* onreply_route[0] {} is equivalent with onreply_route {}*/
1801
+			push($7, &onreply_rt.rlist[DEFAULT_RT]);
1802
+		}else{
1803
+			i_tmp=route_get(&onreply_rt, $3);
1804
+			if (i_tmp==-1){
1805
+				yyerror("internal error");
1806
+				YYABORT;
1807
+			}
1808
+			if (onreply_rt.rlist[i_tmp]){
1809
+				yyerror("duplicate route");
1810
+				YYABORT;
1811
+			}
1812
+			push($7, &onreply_rt.rlist[i_tmp]);
1803 1813
 		}
1804
-		push($6, &onreply_rt.rlist[i_tmp]);
1805 1814
 	}
1806
-	| ROUTE_ONREPLY error { yyerror("invalid onreply_route statement"); }
1815
+	| ROUTE_ONREPLY LBRACK route_name RBRACK error {
1816
+		yyerror("invalid onreply_route statement");
1817
+	}
1807 1818
 	;
1808 1819
 branch_route_stm:
1809 1820
 	ROUTE_BRANCH LBRACE actions RBRACE {
... ...
@@ -247,7 +247,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
247 247
 
248 248
 		/* exec the onreply routing script */
249 249
 		if (onreply_rt.rlist[DEFAULT_RT]){
250
-			set_route_type(ONREPLY_ROUTE);
250
+			set_route_type(CORE_ONREPLY_ROUTE);
251 251
 			ret=run_top_route(onreply_rt.rlist[DEFAULT_RT], msg, &ctx);
252 252
 #ifndef NO_ONREPLY_ROUTE_ERROR
253 253
 			if (unlikely(ret<0)){
... ...
@@ -47,11 +47,13 @@
47 47
  */
48 48
 #define REQUEST_ROUTE (1 << 0)
49 49
 #define FAILURE_ROUTE (1 << 1)
50
-#define ONREPLY_ROUTE (1 << 2)
50
+#define TM_ONREPLY_ROUTE (1 << 2)
51 51
 #define BRANCH_ROUTE  (1 << 3)
52 52
 #define ONSEND_ROUTE  (1 << 4)
53 53
 #define ERROR_ROUTE   (1 << 5)
54 54
 #define LOCAL_ROUTE   (1 << 6)
55
+#define CORE_ONREPLY_ROUTE (1 << 7)
56
+#define ONREPLY_ROUTE (TM_ONREPLY_ROUTE|CORE_ONREPLY_ROUTE)
55 57
 #define EVENT_ROUTE   REQUEST_ROUTE
56 58
 #define ANY_ROUTE     (0xFFFFFFFF)
57 59
 
... ...
@@ -68,7 +70,7 @@ extern int route_type;
68 68
 
69 69
 #define get_route_type()	route_type
70 70
 
71
-#define is_route_type(type) (route_type == (type))
71
+#define is_route_type(type) (route_type & (type))
72 72
 
73 73
 struct route_list{
74 74
 	struct action** rlist;