[sword-svn] r3593 - trunk/bindings/corba/omniorbcpp
scribe at crosswire.org
scribe at crosswire.org
Thu Sep 6 10:01:31 MST 2018
Author: scribe
Date: 2018-09-06 10:01:31 -0700 (Thu, 06 Sep 2018)
New Revision: 3593
Modified:
trunk/bindings/corba/omniorbcpp/server.cpp
trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
Log:
corba bindings. Better handle exit scenarios
Modified: trunk/bindings/corba/omniorbcpp/server.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/server.cpp 2018-07-21 18:08:20 UTC (rev 3592)
+++ trunk/bindings/corba/omniorbcpp/server.cpp 2018-09-06 17:01:31 UTC (rev 3593)
@@ -21,6 +21,7 @@
*/
+#include <csignal>
#include "swordorb-impl.hpp"
#include <iostream>
#include <swmgr.h>
@@ -28,6 +29,7 @@
SWConfig *sysConf = 0;
WebMgr *swordMgr = 0;
+CORBA::ORB_var orb = 0;
class CleanStatics {
public:
@@ -42,6 +44,10 @@
} cleanStatics;
+void term_handler(int signal) {
+ std::cerr << "SIGTERM received, exiting nicely...\n";
+ if (orb) orb->shutdown(!0);
+}
int main (int argc, char** argv)
@@ -65,7 +71,7 @@
// Initialise the ORB.
- CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
+ orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
// Obtain a reference to the root POA.
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
@@ -98,8 +104,13 @@
PortableServer::POAManager_var pman = poa->the_POAManager();
pman->activate();
+ std::signal(SIGTERM, term_handler);
+
+
orb->run();
+ std::cerr << "ORB has stopped running.\n";
orb->destroy();
+ std::cerr << "ORB is destroyed.\n";
}
catch(CORBA::TRANSIENT&) {
std::cerr << "Caught system exception TRANSIENT -- unable to contact the "
Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2018-07-21 18:08:20 UTC (rev 3592)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp 2018-09-06 17:01:31 UTC (rev 3593)
@@ -22,6 +22,7 @@
#include <iostream>
#include <vector>
+#include <csignal>
#include <swordorb-impl.hpp>
@@ -482,7 +483,7 @@
}
void swordorb_SWMgr_i::terminate(){
- exit(0);
+ raise(SIGTERM);
}
::CORBA::Boolean swordorb_SWMgr_i::testConnection(){
More information about the sword-cvs
mailing list