]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[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@234 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

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

index b63f8b7e22cbef733b5073a460b71fe26c9d1da6..9addec75b24b358a98aff9fae4e274789e3edb42 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 a2362156556d34930950ad98559a98bc491fadd3..52f12e510b1145c3e83e8671e4dc43ede9a543fa 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 245f948487bd27f737e41dff0c0337a66932ac1f..34e5e4110860d25616af59847cdfa76e090f9f42 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 48731ca6b28e3ccf077a8820498dd05c8a91ffff..a0f36f04dae5aea4939a53904b3b2171e6658a4d 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 87135a3c2a8c8ed3fb68dcf441add6d36dd0b897..f2b5dba3bd73fa3d980fb6153c6ecc968c3503f0 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 e3956be8ad9b378f45849093083c16afc0e758db..3d357e5502dd58c9ffda9b52ba30128525fc41fe 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 62cedd15e0b685c9df810f23ebbc01541cfbd0a4..12e700818736ed1aac5e960c308dd2241b36a271 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;
   }