--- ipmi_sol.c.orig	2007-07-09 18:11:24.602642000 -0700
+++ ipmi_sol.c	2007-07-09 18:12:45.984211000 -0700
@@ -1414,8 +1414,20 @@
 
 
 
-
-
+/*
+ * Added some retries to the SOL window before declaring it as communication
+ * lost state with the IPMC. Usually helpful in state where the payload is 
+ * reset and sometimes brings the network down and then brings it Up after some 
+ * time. If at the same time SOL sends getDevice Id to check the status of IPMC
+ * and does not get any information, then it just comes out eventhough IPMC is 
+ * available and session is open, but the network was restarting. So added 
+ * more retries before declaring that the session is closed. This is crucial 
+ * as we dont need the SOL session to go down if the IPMC is still available 
+ * but only Network connection restarted because payload got restarted.
+ *
+ * This should not affect the existing functionality.
+ */
+#define MAX_SOL_RETRY           (6)
 /*
  * ipmi_sol_red_pill
  */
@@ -1431,7 +1443,7 @@
 	int    retval;
 	int    buffer_size = intf->session->sol_data.max_inbound_payload_size;
 	int    keepAliveRet = 0;
-
+	int    retrySol = 0;
 	buffer = (char*)malloc(buffer_size);
 	if (buffer == NULL) {
 		lprintf(LOG_ERR, "ipmitool: malloc failure"); 
@@ -1443,6 +1455,9 @@
 
 	enter_raw_mode();
 
+	/* Initialize this variable to zero */
+	retrySol = 0;
+
 	while (! bShouldExit)
 	{
 		FD_ZERO(&read_fds);
@@ -1450,22 +1465,37 @@
 		FD_SET(intf->fd, &read_fds);
 
 		/* Send periodic keepalive packet */
-      if(_use_sol_for_keepalive == 0)
-      {
-         keepAliveRet = ipmi_sol_keepalive_using_getdeviceid(intf);
-      }
-      else
-      {
-         keepAliveRet = ipmi_sol_keepalive_using_sol(intf);
-      }
+      		if(_use_sol_for_keepalive == 0)
+      		{
+			keepAliveRet = ipmi_sol_keepalive_using_getdeviceid(intf);
+		}
+		else
+		{
+         		keepAliveRet = ipmi_sol_keepalive_using_sol(intf);
+      		}
 		
 		if (keepAliveRet != 0)
 		{
-			/* no response to keepalive message */
-			bShouldExit = 1;
-			continue;
+            		/* If it fails to get the response for get Device Id 
+             		 * then we can retry for some time before deactivating the 
+             		 * SOL */
+			if (retrySol == MAX_SOL_RETRY)
+			{
+				/* no response to keepalive message */
+				bShouldExit = 1;
+				continue;
+			}
+			else 
+			{ 
+				/* increment the SOL retries */
+				retrySol++;         
+			}
+		}
+		else
+		{
+			/* if the keep Alive is successful then again reset it to zero */
+			retrySol = 0;
 		}
-
 		/* Wait up to half a second */
 		tv.tv_sec =  0;
 		tv.tv_usec = 500000;
