011fe81
From 547d1e84df5d57c7600ead4556d43d5dbbe33c4b Mon Sep 17 00:00:00 2001
78a3d7d
From: Paulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
78a3d7d
Date: Tue, 21 Jan 2014 10:49:39 -0200
58fe9aa
Subject: [PATCH 036/152] change stop condition to avoid infinite loops
78a3d7d
78a3d7d
In net/net.c there is a while (1) that only exits if there is a stop
78a3d7d
condition and more then 10 packages or if there is no package received.
78a3d7d
78a3d7d
If GRUB is idle and enter in this loop, the only condition to leave is
78a3d7d
if it doesn't have incoming packages. In a network with heavy traffic
78a3d7d
this never happens.
78a3d7d
---
78a3d7d
 ChangeLog           | 12 ++++++++++++
78a3d7d
 grub-core/net/net.c |  2 +-
78a3d7d
 2 files changed, 13 insertions(+), 1 deletion(-)
78a3d7d
78a3d7d
diff --git a/ChangeLog b/ChangeLog
011fe81
index 10abfe2..f69d8c7 100644
78a3d7d
--- a/ChangeLog
78a3d7d
+++ b/ChangeLog
78a3d7d
@@ -1,3 +1,15 @@
78a3d7d
+2014-01-21  Paulo Flabiano Smorigo  <pfsmorigo@br.ibm.com>
78a3d7d
+
78a3d7d
+	* grub-core/net/net.c (receive_packets): Change stop condition to avoid
78a3d7d
+	infinite loops.
78a3d7d
+
78a3d7d
+	In net/net.c there is a while (1) that only exits if there is a stop
78a3d7d
+	condition and more then 10 packages or if there is no package received.
78a3d7d
+
78a3d7d
+	If GRUB is idle and enter in this loop, the only condition to leave is
78a3d7d
+	if it doesn't have incoming packages. In a network with heavy traffic
78a3d7d
+	this never happens.
78a3d7d
+
78a3d7d
 2014-01-19  Colin Watson  <cjwatson@ubuntu.com>
78a3d7d
 
78a3d7d
 	* grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore
78a3d7d
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
78a3d7d
index 0e57e93..56355f3 100644
78a3d7d
--- a/grub-core/net/net.c
78a3d7d
+++ b/grub-core/net/net.c
78a3d7d
@@ -1453,7 +1453,7 @@ receive_packets (struct grub_net_card *card, int *stop_condition)
78a3d7d
 	}
78a3d7d
       card->opened = 1;
78a3d7d
     }
78a3d7d
-  while (1)
78a3d7d
+  while (received < 100)
78a3d7d
     {
78a3d7d
       /* Maybe should be better have a fixed number of packets for each card
78a3d7d
 	 and just mark them as used and not used.  */ 
78a3d7d
-- 
37b39b7
1.9.3
78a3d7d