# HG changeset patch
# User Matt Johnston <matt@ucc.asn.au>
# Date 1369750617 -28800
# Node ID 5de524aec047cf7e1a556b1de170183963cb9af1
# Parent  1d1f80fcbcb3d3abd9ffdcc4ab33dcf0555420b0
limit how much we read from rt_cache etc

diff -r 1d1f80fcbcb3 -r 5de524aec047 random.c
--- a/random.c	Mon May 13 21:35:13 2013 +0800
+++ b/random.c	Tue May 28 22:16:57 2013 +0800
@@ -77,7 +77,7 @@
 	while (len == 0 || readcount < len)
 	{
 		int readlen, wantread;
-		unsigned char readbuf[2048];
+		unsigned char readbuf[4096];
 		if (!already_blocked)
 		{
 			int ret;
@@ -208,12 +208,13 @@
 	process_file(&hs, "/proc/loadavg", 0, 0);
 	process_file(&hs, "/proc/sys/kernel/random/entropy_avail", 0, 0);
 
-	/* Mostly network visible but useful in some situations */
-	process_file(&hs, "/proc/net/netstat", 0, 0);
-	process_file(&hs, "/proc/net/dev", 0, 0);
-	process_file(&hs, "/proc/net/tcp", 0, 0);
+	/* Mostly network visible but useful in some situations.
+	 * Limit size to avoid slowdowns on systems with lots of routes */
+	process_file(&hs, "/proc/net/netstat", 4096, 0);
+	process_file(&hs, "/proc/net/dev", 4096, 0);
+	process_file(&hs, "/proc/net/tcp", 4096, 0);
 	/* Also includes interface lo */
-	process_file(&hs, "/proc/net/rt_cache", 0, 0);
+	process_file(&hs, "/proc/net/rt_cache", 4096, 0);
 	process_file(&hs, "/proc/vmstat", 0, 0);
 #endif