[OpenSM] - add changes in sigint handling for the linux trunk.
authoreitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 8 Mar 2006 13:41:30 +0000 (13:41 +0000)
committereitan <eitan@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 8 Mar 2006 13:41:30 +0000 (13:41 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@234 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/opensm/user/include/opensm/osm_console.h
ulp/opensm/user/include/opensm/osm_opensm.h
ulp/opensm/user/opensm/main.c
ulp/opensm/user/opensm/osm_console.c
ulp/opensm/user/opensm/osm_opensm.c
ulp/opensm/user/opensm/osm_sm.c
ulp/opensm/user/opensm/osm_vl15intf.c

index b63f8b7..9addec7 100644 (file)
@@ -49,6 +49,7 @@
 BEGIN_C_DECLS
 
 void osm_console(osm_opensm_t *p_osm);
+void osm_console_prompt(void);
 
 END_C_DECLS
 
index a236215..52f12e5 100644 (file)
@@ -385,38 +385,12 @@ osm_opensm_wait_for_subnet_up(
 
 /****v* OpenSM/osm_exit_flag 
 */
-extern volatile int osm_exit_flag;
+extern volatile unsigned int osm_exit_flag;
 /* 
 * DESCRIPTION 
 *  Set to one to cause all threads to leave 
 *********/
 
-#ifndef __WIN__
-/****f* OpenSM: OpenSM/osm_reg_sig_handler
-* NAME
-*       osm_reg_sig_handler
-*
-* DESCRIPTION
-*      Registers the common signal handler
-*
-* SYNOPSIS
-*/
-void osm_reg_sig_handler(
-IN osm_opensm_t* const p_osm);
-/*
-* PARAMETERS
-*      p_osm
-*              [in] Pointer to a OpenSM object to handle signals on.
-*
-* RETURN VALUES
-*      None
-*
-* NOTES
-*
-* SEE ALSO
-*********/
-#endif /* __WIN__ */
-
 END_C_DECLS
 
 #endif /* _OSM_OPENSM_H_ */
index 245f948..34e5e41 100644 (file)
@@ -66,7 +66,7 @@
   instantiating more than one opensm object.
 */
 osm_opensm_t osm;
-volatile int osm_exit_flag = 0;
+volatile unsigned int osm_exit_flag = 0;
 
 #define GUID_ARRAY_SIZE 64
 #define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
index 48731ca..a0f36f0 100644 (file)
@@ -38,6 +38,7 @@
 #define _GNU_SOURCE            /* for getline */
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/poll.h>
 #include <opensm/osm_console.h>
 
 #define OSM_COMMAND_LINE_LEN   120
@@ -185,15 +186,27 @@ static void parse_cmd_line(char *line, osm_opensm_t *p_osm)
        }
 }
 
+void osm_console_prompt(void)
+{
+       printf("%s", OSM_COMMAND_PROMPT);
+       fflush(stdout);
+}
+
 void osm_console(osm_opensm_t *p_osm)
 {
+       struct pollfd pollfd;
        char *p_line;
        size_t len;
        ssize_t n;
 
-       printf("\nOpenSM Console\n\n");
-       while (1) {
-               printf("%s", OSM_COMMAND_PROMPT);
+       pollfd.fd = 0;
+       pollfd.events = POLLIN;
+       pollfd.revents = 0;
+
+       if (poll(&pollfd, 1, 10000) <= 0)
+               return;
+
+       if (pollfd.revents|POLLIN) {
                p_line = NULL;
                /* Get input line */
                n = getline(&p_line, &len, stdin);
@@ -205,6 +218,7 @@ void osm_console(osm_opensm_t *p_osm)
                        printf("Input error\n");
                        fflush(stdin);
                }
+               osm_console_prompt();
        }
 }
 
index 87135a3..f2b5dba 100644 (file)
@@ -51,7 +51,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <complib/cl_memory.h>
-#include <complib/cl_signal_osd.h>
 #include <opensm/cl_dispatcher.h>
 #include <complib/cl_passivelock.h>
 #include <vendor/osm_vendor_api.h>
@@ -145,52 +144,6 @@ osm_opensm_create_mcgroups(
    OSM_LOG_EXIT( &p_osm->log );
 }
 
-/**********************************************************************
- * SHUT DOWN IS CONTROLLED BY A GLOBAL EXIT FLAG
- **********************************************************************/
-#ifndef __WIN__
-static osm_opensm_t *__p_osm_to_signal;
-
-void
-__sig_handler(
-   int signum )
-{
-   static int got_signal = 0;
-
-   if( signum != SIGHUP )
-   {
-      if( !got_signal )
-      {
-         got_signal++;
-         printf( "OpenSM: Got signal %d - exiting...\n", signum );
-         osm_exit_flag = 1;
-      }
-   }
-   else
-   {
-      /* a HUP signal should only start a new heavy sweep */
-      __p_osm_to_signal->subn.force_immediate_heavy_sweep = TRUE;
-      osm_state_mgr_process( &__p_osm_to_signal->sm.state_mgr,
-                             OSM_SIGNAL_SWEEP );
-   }
-}
-
-void
-osm_reg_sig_handler(
-   IN osm_opensm_t * const p_osm )
-{
-   __p_osm_to_signal = p_osm;
-#ifndef OSM_VENDOR_INTF_OPENIB 
-   cl_reg_sig_hdl( SIGINT, __sig_handler );
-#endif
-   cl_reg_sig_hdl( SIGTERM, __sig_handler );
-   cl_reg_sig_hdl( SIGHUP, __sig_handler );
-   osm_exit_flag = 0;
-
-   return;
-}
-#endif /* __WIN__ */
-
 /**********************************************************************
  **********************************************************************/
 ib_api_status_t
index e3956be..3d357e5 100644 (file)
@@ -57,7 +57,6 @@
 #include <complib/cl_passivelock.h>
 #include <complib/cl_debug.h>
 #include <iba/ib_types.h>
-#include <complib/cl_signal_osd.h>
 #include <opensm/osm_sm.h>
 #include <opensm/osm_madw.h>
 #include <opensm/osm_log.h>
@@ -84,10 +83,6 @@ __osm_sm_sweeper(
 
    if( p_sm->thread_state == OSM_THREAD_STATE_INIT )
    {
-      osm_log( p_sm->p_log, OSM_LOG_DEBUG,
-               "__osm_sm_sweeper: " "Masking ^C Signals\n" );
-      cl_sig_mask_sigint(  );
-
       p_sm->thread_state = OSM_THREAD_STATE_RUN;
    }
 
index 62cedd1..12e7008 100644 (file)
@@ -53,7 +53,6 @@
 #endif /* HAVE_CONFIG_H */
 
 #include <iba/ib_types.h>
-#include <complib/cl_signal_osd.h>
 #include <complib/cl_memory.h>
 #include <opensm/osm_vl15intf.h>
 #include <opensm/osm_madw.h>
@@ -82,7 +81,6 @@ __osm_vl15_poller(
 
   if ( p_vl->thread_state == OSM_THREAD_STATE_NONE)
   {
-    cl_sig_mask_sigint( );
     p_vl->thread_state = OSM_THREAD_STATE_RUN;
   }