[sr-dev] git:master:f51f81c4: ratelimit Only output error message five times

Olle E. Johansson oej at edvina.net
Wed Feb 4 18:29:07 CET 2015


Module: kamailio
Branch: master
Commit: f51f81c43419891c25b1d77cf0a9fd417989f390
URL: https://github.com/kamailio/kamailio/commit/f51f81c43419891c25b1d77cf0a9fd417989f390

Author: Olle E. Johansson <oej at edvina.net>
Committer: Olle E. Johansson <oej at edvina.net>
Date: 2015-02-04T18:28:37+01:00

ratelimit Only output error message five times

---

Modified: modules/ratelimit/ratelimit.c

---

Diff:  https://github.com/kamailio/kamailio/commit/f51f81c43419891c25b1d77cf0a9fd417989f390.diff
Patch: https://github.com/kamailio/kamailio/commit/f51f81c43419891c25b1d77cf0a9fd417989f390.patch

---

diff --git a/modules/ratelimit/ratelimit.c b/modules/ratelimit/ratelimit.c
index 13961da..dc5748f 100644
--- a/modules/ratelimit/ratelimit.c
+++ b/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",




More information about the sr-dev mailing list