瀏覽代碼

core: return & break are absorbed in expressions

return & break inside an expression do not cause the current route
block or while/switch statement to end.
E.g.: $v = { return 1; }  will not end the current route, will
only set $v to 1.
(cherry picked from commit 65b64bca77b18f7ee964119e1b3b363d66189c3e)
Andrei Pelinescu-Onciul 15 年之前
父節點
當前提交
253ad295e4
共有 2 個文件被更改,包括 16 次插入8 次删除
  1. 8 4
      lvalue.c
  2. 8 4
      rvalue.c

+ 8 - 4
lvalue.c

@@ -100,9 +100,11 @@ inline static int lval_avp_assign(struct run_act_ctx* h, struct sip_msg* msg,
 			break;
 		case RV_ACTION_ST:
 			flags=avp->type & ~AVP_VAL_STR;
-			if (rv->v.action)
+			if (rv->v.action) {
 				value.n=run_actions_safe(h, rv->v.action, msg);
-			else
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+														    break in expr*/
+			} else
 				value.n=-1;
 			ret=value.n;
 			break;
@@ -275,9 +277,11 @@ inline static int lval_pvar_assign(struct run_act_ctx* h, struct sip_msg* msg,
 			break;
 		case RV_ACTION_ST:
 			pval.flags=PV_TYPE_INT|PV_VAL_INT;
-			if (rv->v.action)
+			if (rv->v.action) {
 				pval.ri=run_actions_safe(h, rv->v.action, msg);
-			else
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+														    break in expr*/
+			} else
 				pval.ri=0;
 			ret=pval.ri;
 			break;

+ 8 - 4
rvalue.c

@@ -893,9 +893,11 @@ int rval_get_int(struct run_act_ctx* h, struct sip_msg* msg,
 			}
 			break;
 		case RV_ACTION_ST:
-			if (rv->v.action)
+			if (rv->v.action) {
 				*i=(run_actions_safe(h, rv->v.action, msg)>0);
-			else
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+														    break in expr*/
+			} else
 				*i=0;
 			break;
 		case RV_SEL:
@@ -1088,9 +1090,11 @@ int rval_get_tmp_str(struct run_act_ctx* h, struct sip_msg* msg,
 			*tmpv=rv->v.s;
 			break;
 		case RV_ACTION_ST:
-			if (rv->v.action)
+			if (rv->v.action) {
 				i=(run_actions_safe(h, rv->v.action, msg)>0);
-			else
+				h->run_flags &= ~(RETURN_R_F|BREAK_R_F); /* catch return &
+														    break in expr*/
+			} else
 				i=0;
 			tmpv->s=int2str(i, &tmpv->len);
 			break;