Browse Source

ratelimit Only output error message five times

Olle E. Johansson 10 năm trước cách đây
mục cha
commit
f51f81c434
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      modules/ratelimit/ratelimit.c

+ 6 - 1
modules/ratelimit/ratelimit.c

@@ -325,9 +325,14 @@ 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 output this error message five times */
+		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",