[ofa-general] ***SPAM*** Re: [PATCH] Fix further bugs around console closure and clean up code.

Sasha Khapyorsky sashak at voltaire.com
Sun Apr 12 00:23:20 PDT 2009


On 17:13 Tue 07 Apr     , Ira Weiny wrote:
> 
> This patch fixes all this by removing console_close, making cio_close close
> only the connection, and fixing osm_console_exit to properly clean up from
> osm_console_init.
> 
> Signed-off-by: Ira Weiny <weiny2 at llnl.gov>

This patch in its original form breaks OpenSM build with
--disable-console-socket (which is default now). So applied with such
changes (also clean unused p_log variable warning):


diff --git a/opensm/include/opensm/osm_console_io.h b/opensm/include/opensm/osm_console_io.h
index d1dbbdd..b51cbf7 100644
--- a/opensm/include/opensm/osm_console_io.h
+++ b/opensm/include/opensm/osm_console_io.h
@@ -85,6 +85,8 @@ int is_console_enabled(osm_subn_opt_t *p_opt);
 int cio_open(osm_console_t * p_oct, int new_fd, osm_log_t * p_log);
 int cio_close(osm_console_t * p_oct, osm_log_t * p_log);
 int is_authorized(osm_console_t * p_oct);
+#else
+#define cio_close(c, log)
 #endif
 
 END_C_DECLS
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index 182c64e..00264e5 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -1385,7 +1385,6 @@ int osm_console(osm_opensm_t * p_osm)
 	struct pollfd *fds;
 	nfds_t nfds;
 	osm_console_t *p_oct = &p_osm->console;
-	osm_log_t *p_log = &p_osm->log;
 
 	pollfd[0].fd = p_oct->socket;
 	pollfd[0].events = POLLIN;
@@ -1418,7 +1417,7 @@ int osm_console(osm_opensm_t * p_osm)
 		socklen_t len = sizeof(sin);
 		struct hostent *hent;
 		if ((new_fd = accept(p_oct->socket, &sin, &len)) < 0) {
-			OSM_LOG(p_log, OSM_LOG_ERROR,
+			OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
 				"ERR 4B04: Failed to accept console socket: %s\n",
 				strerror(errno));
 			p_oct->in_fd = -1;
@@ -1437,9 +1436,9 @@ int osm_console(osm_opensm_t * p_osm)
 			snprintf(p_oct->client_hn, 128, "%s", hent->h_name);
 		}
 		if (is_authorized(p_oct)) {
-			cio_open(p_oct, new_fd, p_log);
+			cio_open(p_oct, new_fd, &p_osm->log);
 		} else {
-			OSM_LOG(p_log, OSM_LOG_ERROR,
+			OSM_LOG(&p_osm->log, OSM_LOG_ERROR,
 				"ERR 4B05: Console connection denied: %s (%s)\n",
 				p_oct->client_hn, p_oct->client_ip);
 			close(new_fd);
@@ -1459,7 +1458,7 @@ int osm_console(osm_opensm_t * p_osm)
 				osm_console_prompt(p_oct->out);
 			}
 		} else
-			cio_close(p_oct, p_log);
+			cio_close(p_oct, &p_osm->log);
 		if (p_line)
 			free(p_line);
 		return 0;
@@ -1469,7 +1468,7 @@ int osm_console(osm_opensm_t * p_osm)
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
 		/* If we are using a socket, we close the current connection */
 		if (p_oct->socket >= 0) {
-			cio_close(p_oct, p_log);
+			cio_close(p_oct, &p_osm->log);
 			return 0;
 		}
 #endif


Thanks,

Sasha



More information about the general mailing list