浏览代码

pipelimit Only output error five times

Olle E. Johansson 10 年之前
父节点
当前提交
1dac670893
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      modules/pipelimit/pipelimit.c

+ 7 - 1
modules/pipelimit/pipelimit.c

@@ -223,9 +223,15 @@ static int get_cpuload(double * load)
 	FILE * f = fopen("/proc/stat", "r");
 	double vload;
 	int ncpu;
+	static int errormsg = 0;
 
 	if (! f) {
-		LM_ERR("could not open /proc/stat\n");
+		/* Only write this error message five times. Otherwise you will annoy
+		   BSD-ish system administrators. */
+		if (errormsg < 5) {
+			LM_ERR("could not open /proc/stat\n");
+			errormsg++;
+		}
 		return -1;
 	}
 	if (fscanf(f, "cpu  %lld%lld%lld%lld%lld%lld%lld%lld",