Skip to content
Snippets Groups Projects
Commit 95cda253 authored by Serguei Kolos's avatar Serguei Kolos
Browse files

Add Bidir GIOP support

parent f339176b
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,8 @@ class IPCCore
static bool isInitialised() throw();
static bool isBidirUsed() throw();
static CORBA::ORB_var getORB ();
static PortableServer::POA_var getRootPOA ();
......@@ -66,6 +68,7 @@ class IPCCore
static void atExitFun();
static bool s_at_exit_registered;
static bool s_bidir_used;
static boost::mutex * s_guard;
static CORBA::ORB_ptr s_orb_instance;
static PortableServer::POA_ptr s_root_poa;
......
......@@ -67,7 +67,7 @@ private:
template<class T, class TP, class PP>
IPCObjectAdapter::IPCObjectAdapter(IPCObjectBase<T, TP, PP> * object)
{
CORBA::PolicyList pl(6);
CORBA::PolicyList pl(7);
pl.length(6);
PortableServer::POA_var root_poa = IPCCore::getRootPOA();
......@@ -79,6 +79,14 @@ IPCObjectAdapter::IPCObjectAdapter(IPCObjectBase<T, TP, PP> * object)
pl[4] = root_poa->create_servant_retention_policy(PortableServer::RETAIN);
pl[5] = root_poa->create_id_uniqueness_policy(PortableServer::UNIQUE_ID);
if (IPCCore::isBidirUsed()) {
CORBA::ORB_var orb = IPCCore::getORB();
CORBA::Any bidir;
bidir <<= BiDirPolicy::BOTH;
pl.length(7);
pl[6] = orb->create_policy(BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, bidir);
}
std::string poa_id = ipc::util::getTypeName(object) + object->poa_id_suffix();
try {
......
......@@ -28,6 +28,7 @@ namespace ipc
}
bool IPCCore::s_at_exit_registered = false;
bool IPCCore::s_bidir_used = false;
boost::mutex * IPCCore::s_guard = new boost::mutex();
CORBA::ORB_ptr IPCCore::s_orb_instance;
PortableServer::POA_ptr IPCCore::s_root_poa;
......@@ -163,7 +164,8 @@ IPCCore::extractOptions( int & argc, char ** argv )
}
catch (const omni::orbOptions::BadParam& ex)
{
throw daq::ipc::BadOptionValue( ERS_HERE, (const char *)ex.key, (const char *)ex.value, (const char *)ex.why );
throw daq::ipc::BadOptionValue( ERS_HERE, (const char *)ex.key,
(const char *)ex.value, (const char *)ex.why );
}
omni::orbOptions::sequenceString_var newOpts;
......@@ -205,6 +207,8 @@ IPCCore::init( const std::list< std::pair< std::string, std::string > > & opt )
throw daq::ipc::AlreadyInitialized( ERS_HERE );
}
s_bidir_used = getenv("TDAQ_IPC_USE_BIDIR") != 0;
///////////////////////////////////
// check and set the timeout value
///////////////////////////////////
......@@ -217,12 +221,13 @@ IPCCore::init( const std::list< std::pair< std::string, std::string > > & opt )
in >> val;
if ( val < 1000 )
{
throw daq::ipc::BadOptionValue( ERS_HERE, "Timeout", env, "It must be more then 1000 milliseconds." );
throw daq::ipc::BadOptionValue( ERS_HERE,
"Timeout", env, "It must be more then 1000 milliseconds." );
}
timeout = env;
}
const char* (*options)[2] = new const char*[opt.size()+4][2];
const char* (*options)[2] = new const char*[opt.size()+10][2];
int idx = 0;
options[idx][0] = "clientCallTimeOutPeriod";
options[idx][1] = timeout.c_str();
......@@ -233,9 +238,28 @@ IPCCore::init( const std::list< std::pair< std::string, std::string > > & opt )
options[idx][0] = "verifyObjectExistsAndType";
options[idx][1] = "0";
idx++;
options[idx][0] = "supportCurrent";
options[idx][1] = "0";
idx++;
if (s_bidir_used) {
options[idx][0] = "offerBiDirectionalGIOP";
options[idx][1] = "1";
idx++;
options[idx][0] = "acceptBiDirectionalGIOP";
options[idx][1] = "1";
idx++;
options[idx][0] = "clientTransportRule";
options[idx][1] = "* unix,tcp,bidir";
idx++;
options[idx][0] = "serverTransportRule";
options[idx][1] = "* unix,tcp,bidir";
idx++;
options[idx][0] = "supportCurrent";
options[idx][1] = "1";
idx++;
} else {
options[idx][0] = "supportCurrent";
options[idx][1] = "0";
idx++;
}
for( list< pair< string, string > >::const_iterator it = opt.begin(); it != opt.end(); ++idx, ++it )
{
......@@ -366,6 +390,14 @@ IPCCore::isInitialised() throw()
return ( !CORBA::is_nil(s_orb_instance) && !CORBA::is_nil(s_root_poa) );
}
bool
IPCCore::isBidirUsed() throw()
{
boost::mutex::scoped_lock ml( *s_guard );
return s_bidir_used;
}
CORBA::ORB_var
IPCCore::getORB ()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment