Sasha, the second one.

From 7a82f221e5e02ddc660aa917dc95256774fdc508 Mon Sep 17 00:00:00 2001
From: Tim Meier <[EMAIL PROTECTED]>
Date: Mon, 4 Feb 2008 14:49:34 -0800
Subject: [PATCH] opensm: osm_console - cleanup in preparation for adding 
OpenSSL option

Trivial reorganization and cleanup, no new functionality.  This is to
help minimize the impact (on existing code) of adding new features
to the Console (such as OpenSSL).

Signed-off-by: Tim Meier <[EMAIL PROTECTED]>
---
 opensm/include/opensm/osm_console.h |    5 +--
 opensm/opensm/main.c                |   15 ++++-------
 opensm/opensm/osm_console.c         |   45 ++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/opensm/include/opensm/osm_console.h 
b/opensm/include/opensm/osm_console.h
index 33e41e7..8b31d6a 100644
--- a/opensm/include/opensm/osm_console.h
+++ b/opensm/include/opensm/osm_console.h
@@ -61,8 +61,7 @@
 BEGIN_C_DECLS
 void osm_console_init(osm_subn_opt_t * opt, osm_opensm_t * p_osm);
 void osm_console(osm_opensm_t * p_osm);
-void osm_console_prompt(FILE * out);
-void osm_console_close_socket(osm_opensm_t * p_osm);
-
+void osm_console_exit(osm_opensm_t * p_osm);
+int is_console_enabled(osm_subn_opt_t *p_opt);
 END_C_DECLS
 #endif                         /* _OSM_CONSOLE_H_ */
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 239de84..3663232 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -553,18 +553,14 @@ static int daemonize(osm_opensm_t * osm)
  **********************************************************************/
 int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * p_osm)
 {
-       osm_console_init(p_opt, p_osm);
+       if(is_console_enabled(p_opt))
+         osm_console_init(p_opt, p_osm);

        /*
-          Sit here forever
+          Sit here forever - dwell or do console i/o & cmds
         */
        while (!osm_exit_flag) {
-               if (strcmp(p_opt->console, OSM_LOCAL_CONSOLE) == 0
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-                   || strcmp(p_opt->console, OSM_REMOTE_CONSOLE) == 0
-                   || strcmp(p_opt->console, OSM_LOOPBACK_CONSOLE) == 0
-#endif
-                   )
+               if (is_console_enabled(p_opt))
                        osm_console(p_osm);
                else
                        cl_thread_suspend(10000);
@@ -580,7 +576,8 @@ int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * 
p_osm)
                        osm_opensm_sweep(p_osm);
                }
        }
-       osm_console_close_socket(p_osm);
+       if(is_console_enabled(p_opt))
+         osm_console_exit(p_osm);
        return 0;
 }
 /**********************************************************************
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index d0a632f..63ee1de 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -773,6 +773,42 @@ static void portstatus_parse(char **p_last, osm_opensm_t * 
p_osm, FILE * out)
        fprintf(out, "\n");
 }

+static int is_local(char* str)
+{
+  // convenience - checks if just stdin/stdout
+ if(str)
+   return (strcmp(str, OSM_LOCAL_CONSOLE) == 0);
+return 0;
+}
+
+static int is_loopback(char* str)
+{
+  // convenience - checks if socket based connection
+ if(str)
+   return (strcmp(str, OSM_LOOPBACK_CONSOLE) == 0);
+return 0;
+}
+
+static int is_remote(char* str)
+{
+  // convenience - checks if socket based connection
+ if(str)
+   return (strcmp(str, OSM_REMOTE_CONSOLE) == 0)
+       || is_loopback(str);
+return 0;
+}
+
+int is_console_enabled(osm_subn_opt_t *p_opt)
+{
+  // checks for a variety of types of consoles - default is off or 0
+ if(p_opt)
+   return (is_local(p_opt->console)
+       || is_loopback(p_opt->console)
+       || is_remote(p_opt->console));
+return 0;
+}
+
+
 #ifdef ENABLE_OSM_PERF_MGR
 static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 {
@@ -924,7 +960,7 @@ static void parse_cmd_line(char *line, osm_opensm_t * p_osm)
        }
 }

-void osm_console_prompt(FILE * out)
+static void osm_console_prompt(FILE * out)
 {
        if (out) {
                fprintf(out, "OpenSM %s", OSM_COMMAND_PROMPT);
@@ -989,6 +1025,13 @@ void osm_console_init(osm_subn_opt_t * opt, osm_opensm_t 
* p_osm)
        }
 }

+/* clean up and release resouces */
+void osm_console_exit(osm_opensm_t * p_osm)
+{
+       // clean up and release resouces, currently just close the socket
+       osm_console_close_socket(p_osm);
+}
+
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
 static void handle_osm_connection(osm_opensm_t * p_osm, int new_fd,
                                  char *client_ip, char *client_hn)
--
1.5.1



--
Timothy A. Meier
Computer Scientist
ICCD/High Performance Computing
925.422.3341
[EMAIL PROTECTED]
>From 7a82f221e5e02ddc660aa917dc95256774fdc508 Mon Sep 17 00:00:00 2001
From: Tim Meier <[EMAIL PROTECTED]>
Date: Mon, 4 Feb 2008 14:49:34 -0800
Subject: [PATCH] opensm: osm_console - cleanup in preparation for adding 
OpenSSL option

Trivial reorganization and cleanup, no new functionality.  This is to
help minimize the impact (on existing code) of adding new features
to the Console (such as OpenSSL).

Signed-off-by: Tim Meier <[EMAIL PROTECTED]>
---
 opensm/include/opensm/osm_console.h |    5 +--
 opensm/opensm/main.c                |   15 ++++-------
 opensm/opensm/osm_console.c         |   45 ++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/opensm/include/opensm/osm_console.h 
b/opensm/include/opensm/osm_console.h
index 33e41e7..8b31d6a 100644
--- a/opensm/include/opensm/osm_console.h
+++ b/opensm/include/opensm/osm_console.h
@@ -61,8 +61,7 @@
 BEGIN_C_DECLS
 void osm_console_init(osm_subn_opt_t * opt, osm_opensm_t * p_osm);
 void osm_console(osm_opensm_t * p_osm);
-void osm_console_prompt(FILE * out);
-void osm_console_close_socket(osm_opensm_t * p_osm);
-
+void osm_console_exit(osm_opensm_t * p_osm);
+int is_console_enabled(osm_subn_opt_t *p_opt);
 END_C_DECLS
 #endif                         /* _OSM_CONSOLE_H_ */
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 239de84..3663232 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -553,18 +553,14 @@ static int daemonize(osm_opensm_t * osm)
  **********************************************************************/
 int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * p_osm)
 {
-       osm_console_init(p_opt, p_osm);
+       if(is_console_enabled(p_opt))
+         osm_console_init(p_opt, p_osm);
 
        /*
-          Sit here forever
+          Sit here forever - dwell or do console i/o & cmds
         */
        while (!osm_exit_flag) {
-               if (strcmp(p_opt->console, OSM_LOCAL_CONSOLE) == 0
-#ifdef ENABLE_OSM_CONSOLE_SOCKET
-                   || strcmp(p_opt->console, OSM_REMOTE_CONSOLE) == 0
-                   || strcmp(p_opt->console, OSM_LOOPBACK_CONSOLE) == 0
-#endif
-                   )
+               if (is_console_enabled(p_opt))
                        osm_console(p_osm);
                else
                        cl_thread_suspend(10000);
@@ -580,7 +576,8 @@ int osm_manager_loop(osm_subn_opt_t * p_opt, osm_opensm_t * 
p_osm)
                        osm_opensm_sweep(p_osm);
                }
        }
-       osm_console_close_socket(p_osm);
+       if(is_console_enabled(p_opt))
+         osm_console_exit(p_osm);
        return 0;
 }
 /**********************************************************************
diff --git a/opensm/opensm/osm_console.c b/opensm/opensm/osm_console.c
index d0a632f..63ee1de 100644
--- a/opensm/opensm/osm_console.c
+++ b/opensm/opensm/osm_console.c
@@ -773,6 +773,42 @@ static void portstatus_parse(char **p_last, osm_opensm_t * 
p_osm, FILE * out)
        fprintf(out, "\n");
 }
 
+static int is_local(char* str)
+{
+  // convenience - checks if just stdin/stdout
+ if(str)
+   return (strcmp(str, OSM_LOCAL_CONSOLE) == 0);
+return 0;
+}
+
+static int is_loopback(char* str)
+{
+  // convenience - checks if socket based connection
+ if(str)
+   return (strcmp(str, OSM_LOOPBACK_CONSOLE) == 0);
+return 0;
+}
+
+static int is_remote(char* str)
+{
+  // convenience - checks if socket based connection
+ if(str)
+   return (strcmp(str, OSM_REMOTE_CONSOLE) == 0)
+       || is_loopback(str);
+return 0;
+}
+
+int is_console_enabled(osm_subn_opt_t *p_opt)
+{
+  // checks for a variety of types of consoles - default is off or 0
+ if(p_opt)
+   return (is_local(p_opt->console)
+       || is_loopback(p_opt->console)
+       || is_remote(p_opt->console));
+return 0;
+}
+
+
 #ifdef ENABLE_OSM_PERF_MGR
 static void perfmgr_parse(char **p_last, osm_opensm_t * p_osm, FILE * out)
 {
@@ -924,7 +960,7 @@ static void parse_cmd_line(char *line, osm_opensm_t * p_osm)
        }
 }
 
-void osm_console_prompt(FILE * out)
+static void osm_console_prompt(FILE * out)
 {
        if (out) {
                fprintf(out, "OpenSM %s", OSM_COMMAND_PROMPT);
@@ -989,6 +1025,13 @@ void osm_console_init(osm_subn_opt_t * opt, osm_opensm_t 
* p_osm)
        }
 }
 
+/* clean up and release resouces */
+void osm_console_exit(osm_opensm_t * p_osm)
+{
+       // clean up and release resouces, currently just close the socket
+       osm_console_close_socket(p_osm);
+}
+
 #ifdef ENABLE_OSM_CONSOLE_SOCKET
 static void handle_osm_connection(osm_opensm_t * p_osm, int new_fd,
                                  char *client_ip, char *client_hn)
-- 
1.5.1

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to