ipc_Shutdown Class Reference

#include <ipc_shutdown.h>

Inheritance diagram for ipc_Shutdown:

Inheritance graph
[legend]
Collaboration diagram for ipc_Shutdown:

Collaboration graph
[legend]

List of all members.


Detailed Description

Helper class to shut down on signal.

Definition at line 32 of file ipc_shutdown.h.


Public Member Functions

 ipc_Shutdown (bool a_shutdownCorbaOnSignal)
virtual void * RunUndetached (void *arg)

Private Attributes

 log_CLASSID_m
const bool m_shutdownCorbaOnSignal

Constructor & Destructor Documentation

ipc_Shutdown::ipc_Shutdown ( bool  a_shutdownCorbaOnSignal  ) 

Definition at line 52 of file ipc_shutdown.cpp.

References log_FUNC_A_m, sem_finalize, sem_hup, sem_signal, sem_stop, and SignalHandler().

00053     : m_shutdownCorbaOnSignal(a_shutdownCorbaOnSignal) {
00054 
00055     log_FUNC_A_m(ipc_Shutdown,
00056         "shutdown = " << (a_shutdownCorbaOnSignal? "Yes" : "No"));
00057 
00058     sem_init(&sem_signal, 0, 0);
00059     sem_init(&sem_hup, 0, 0);
00060     sem_init(&sem_finalize, 0, 0);
00061     sem_init(&sem_stop, 0, 0);
00062 
00063     {
00064         struct sigaction action;
00065         action.sa_handler = SignalHandler;
00066         sigemptyset(&action.sa_mask);
00067         action.sa_flags = 0;
00068 
00069 #if 0 // -------------------------------------------------
00070 
00071 //#define SIGHUP          1       /* Hangup (POSIX).  */
00072 //#define SIGINT          2       /* Interrupt (ANSI).  */
00073 #define SIGQUIT         3       /* Quit (POSIX).  */
00074 #define SIGILL          4       /* Illegal instruction (ANSI).  */
00075 #define SIGTRAP         5       /* Trace trap (POSIX).  */
00076 #define SIGABRT         6       /* Abort (ANSI).  */
00077 #define SIGIOT          6       /* IOT trap (4.2 BSD).  */
00078 #define SIGBUS          7       /* BUS error (4.2 BSD).  */
00079 #define SIGFPE          8       /* Floating-point exception (ANSI).  */
00080 #define SIGUSR1         10      /* User-defined signal 1 (POSIX).  */
00081 #define SIGSEGV         11      /* Segmentation violation (ANSI).  */
00082 #define SIGUSR2         12      /* User-defined signal 2 (POSIX).  */
00083 #define SIGPIPE         13      /* Broken pipe (POSIX).  */
00084 #define SIGALRM         14      /* Alarm clock (POSIX).  */
00085 //#define SIGTERM         15      /* Termination (ANSI).  */
00086 #define SIGSTKFLT       16      /* Stack fault.  */
00087 #define SIGCLD          SIGCHLD /* Same as SIGCHLD (System V).  */
00088 #define SIGCHLD         17      /* Child status has changed (POSIX).  */
00089 #define SIGCONT         18      /* Continue (POSIX).  */
00090 #define SIGSTOP         19      /* Stop, unblockable (POSIX).  */
00091 #define SIGTSTP         20      /* Keyboard stop (POSIX).  */
00092 #define SIGTTIN         21      /* Background read from tty (POSIX).  */
00093 #define SIGTTOU         22      /* Background write to tty (POSIX).  */
00094 #define SIGURG          23      /* Urgent condition on socket (4.2 BSD).  */
00095 #define SIGXCPU         24      /* CPU limit exceeded (4.2 BSD).  */
00096 #define SIGXFSZ         25      /* File size limit exceeded (4.2 BSD).  */
00097 #define SIGVTALRM       26      /* Virtual alarm clock (4.2 BSD).  */
00098 #define SIGPROF         27      /* Profiling alarm clock (4.2 BSD).  */
00099 #define SIGWINCH        28      /* Window size change (4.3 BSD, Sun).  */
00100 #define SIGPOLL         SIGIO   /* Pollable event occurred (System V).  */
00101 #define SIGIO           29      /* I/O now possible (4.2 BSD).  */
00102 #define SIGPWR          30      /* Power failure restart (System V).  */
00103 #define SIGSYS          31      /* Bad system call.  */
00104 
00105 #endif // -------------------------------------------------
00106 
00107         sigaction(SIGHUP, &action, 0);
00108         sigaction(SIGINT, &action, 0);
00109         sigaction(SIGTERM, &action, 0);
00110     }
00111 }

Here is the call graph for this function:


Member Function Documentation

void * ipc_Shutdown::RunUndetached ( void *  arg  )  [virtual]

Reimplemented from cmn_Thread.

Definition at line 113 of file ipc_shutdown.cpp.

References dbg_LOW, log_DBG_m, log_FUNC_m, m_shutdownCorbaOnSignal, NULL, ipc_Corba::RemoveMajorServant(), sem_finalize, sem_hup, sem_signal, and sem_stop.

00113                                            {
00114     log_FUNC_m(RunUndetached);
00115 
00116     for (;;) {
00117         sem_wait(&sem_signal);
00118         log_DBG_m(dbg_LOW, "Got semaphore.");
00119 
00120         if (sem_trywait(&sem_stop) == 0) {
00121             log_DBG_m(dbg_LOW, "Got signal to stop the thread.");
00122             break;
00123         };
00124 
00125         if (sem_trywait(&sem_hup) == 0) {
00126             log_DBG_m(dbg_LOW, "Got SIGHUP.");
00127             if (m_shutdownCorbaOnSignal) {
00128                 // do whatever you need to do here on SIGHUP (reconfigure, etc.)
00129                 ipc_Corba::RemoveMajorServant();
00130             }
00131             else {
00132                 log_DBG_m(dbg_LOW, "NOTE: CORBA will not be shut down. Signal will be ignored.");
00133             }
00134         }
00135 
00136         if (sem_trywait(&sem_finalize) == 0) {
00137             log_DBG_m(dbg_LOW, "Got INIT/SIGTERM.");
00138             if (m_shutdownCorbaOnSignal) {
00139                 ipc_Corba::RemoveMajorServant();
00140             }
00141             else {
00142                 log_DBG_m(dbg_LOW, "NOTE: CORBA will not be shut down. Signal will be ignored.");
00143             }
00144             break;
00145         };
00146     };
00147     return NULL;
00148 }

Here is the call graph for this function:


Member Data Documentation

Reimplemented from cmn_Thread.

Definition at line 38 of file ipc_shutdown.h.

Definition at line 40 of file ipc_shutdown.h.

Referenced by RunUndetached().


The documentation for this class was generated from the following files:

Generated on Mon Feb 27 19:41:13 2012 for OPENARCHIVE by  doxygen 1.5.6