[MEDIUM] limit the number of events returned by *poll*

By default, epoll/kqueue used to return as many events as possible.
This could sometimes cause huge latencies (latencies of up to 400 ms
have been observed with many thousands of fds at once). Limiting the
number of events returned also reduces the latency by avoiding too
many blind processing. The value is set to 200 by default and can be
changed in the global section using the tune.maxpollevents parameter.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 5045ed2..69f11e0 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -276,6 +276,17 @@
 	else if (!strcmp(args[0], "stats")) {
 		global.mode |= MODE_STATS;
 	}
+	else if (!strcmp(args[0], "tune.maxpollevents")) {
+		if (global.tune.maxpollevents != 0) {
+			Alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
+			return 0;
+		}
+		if (*(args[1]) == 0) {
+			Alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]);
+			return -1;
+		}
+		global.tune.maxpollevents = atol(args[1]);
+	}
 	else if (!strcmp(args[0], "uid")) {
 		if (global.uid != 0) {
 			Alert("parsing [%s:%d] : user/uid already specified. Continuing.\n", file, linenum);