[openib-general] [PATCH 2/2]: OpenSM/osm_console.c: Handle telnet disconnects better

Hal Rosenstock halr at voltaire.com
Mon Jan 8 04:20:25 PST 2007


OpenSM/osm_console.c: Handle telnet disconnects better

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
Signed-off-by: Hal Rosenstock <halr at voltaire.com>

diff --git a/osm/opensm/osm_console.c b/osm/opensm/osm_console.c
index 420acc2..8d770aa 100644
--- a/osm/opensm/osm_console.c
+++ b/osm/opensm/osm_console.c
@@ -336,7 +336,7 @@ void osm_console(osm_opensm_t *p_osm)
 	pollfd[1].events = POLLIN|POLLOUT;
 	pollfd[1].revents = 0;
 
-	if (poll(pollfd, 2, 10000) <= 0)
+	if (poll(pollfd, pollfd[1].fd >= 0 ? 2 : 1, 10000) <= 0)
 		return;
 
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
@@ -382,11 +382,10 @@ void osm_console(osm_opensm_t *p_osm)
 		if (n > 0) {
 			/* Parse and act on input */
 			parse_cmd_line(p_line, p_osm);
+			osm_console_prompt(p_osm->console.out);
+		} else
+			osm_console_close_socket(p_osm);
+		if (p_line)
 			free(p_line);
-		} else {
-			fprintf(p_osm->console.out, "Input error\n");
-			fflush(p_osm->console.out);
-		}
-		osm_console_prompt(p_osm->console.out);
 	}
 }







More information about the general mailing list