Problem
- Product Name: VisiBroker
- Product Version: 7.0, 8.0
- Product Component: ORB
- Platform/OS version: All
- JDK: All
In many occasions, user application needs tocatch the signal and perform customized execution based on the typeof signal. The application may want to catch is theSIGTERM signal during orb->shutdown(). Theshutdown() may hang or the application may encounter CORBA_BAD_INV_ORDER error.
Resolution
In multi-threading environment, some operating system tends to send signal to thread in a random fashion. VisiBroker has its own signal handling thread, which will block and manage all the signals from system to VisiBroker thread. To use application self defined signal handler, the property vbroker.orb.asyncSigwait=0 must be set.
Generally, in signal handler, the execution should be as fast as possible and some of the possible operations are setting a flag or to change a condition for mutex or semaphore.
ORB->shutdown(true) is a blocking call and will wait for all VisiBroker worker threads to complete execution before shutting down the VisiBroker orb. If this operation is within the signal handler, it will cause the application to hang as the control is never passed back to the operating system.
Operation which creates new threads such as Orb->init() is also not recommended to be called in the signal handler.Otherwise, it will cause the VisiBroker threads execution out of order and cause error.
The correct way of using shutdown() with signal handler is: there should be respective thread dedicated for shutdown(). Inside the signal handler, user only changes the flag or condition for the threads to execute.
Please also refer the below articles about Signal Handling in VisiBroker:
[[wiki:Signal handling in VisiBroker for C application (Part One) |Unix/Linux signal handling issues in a multi-threaded application, Part One]] and [[wiki:Signal handling in VisiBroker for C application (Part Two) | Part Two]].
#Security
#VisiBroker
#orb-