浏览代码

pipelimit: update the limit of pipe for pl_check(pipeid, alg, limit)

- affects the dynamic pipes that could have been created by same
  function on a previous execution, allowing to be on-the-fly updated
- reported by Alex Balashov
Daniel-Constantin Mierla 11 年之前
父节点
当前提交
280f947eac
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      modules/pipelimit/pipelimit.c

+ 6 - 3
modules/pipelimit/pipelimit.c

@@ -625,9 +625,9 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg,
 	if(msg==NULL)
 		return -1;
 
-	if(fixup_get_ivalue(msg, (gparam_t*)p3limit, &limit)!=0 || limit<=0)
+	if(fixup_get_ivalue(msg, (gparam_t*)p3limit, &limit)!=0 || limit<0)
 	{
-		LM_ERR("invalid limit value\n");
+		LM_ERR("invalid limit value: %d\n", limit);
 		return -1;
 	}
 
@@ -645,7 +645,7 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg,
 		return -1;
 	}
 
-	pipe = pl_pipe_get(&pipeid, 0);
+	pipe = pl_pipe_get(&pipeid, 1);
 	if(pipe==NULL)
 	{
 		LM_DBG("pipe not found [%.*s] - trying to add it\n",
@@ -663,6 +663,9 @@ static int w_pl_check3(struct sip_msg* msg, char *p1pipe, char *p2alg,
 				pipeid.len, pipeid.s);
 			return -2;
 		}
+	} else {
+		if(limit>0) pipe->limit = limit;
+		pl_pipe_release(&pipe->name);
 	}
 
 	return pl_check(msg, &pipeid);