We are having some strange problem with some of our CORBA
applications : 99% of the time, the applications die properly with a
Ctrl-C but sometimes, they freeze on the orb->shutdown(true); call. We
are using VB6.5 on AIX 5.3.
I've written a test application and noticed that setting the
BIND_SUPPORT_POLICY_TYPE to PortableServerExt::BY_POA, all works fine,
no hangs. If we set it to PortableServerExt::BY_INSTANCE, the test
application always freeze on the orb->shutdown. I've tried
shutdown(true), shutdown(false), nothing works. In the test
application, we just create the server, activate it in persistent
mode, deactivate, etc.. So we do not have any connection to that
server....
Any suggestion on what can cause this strange behaviour ?
Regards
Giovanni
Here is the test program with its IDL
//////////////////////////////
test.idl /////////////////////////////////
#ifndef _IDL_TEST_
#define _IDL_TEST_
interface testInterface
{
unsigned long getVersionNumber();
};
#endif
//////////////////////////////////
testImpl.h ///////////////////////////
#include "test_s.hh"
class testImpl : public virtual POA_testInterface
{
public:
testImpl();
virtual ::CORBA::ULong getVersionNumber() throw();
};
////////////////////////////////
testImpl.cpp ///////////////////////////
#include "testImpl.h"
testImpl::testImpl() : POA_testInterface()
{
}
::CORBA::ULong testImpl::getVersionNumber() throw()
{
std::cout << "we are in getVersionNumber" << std::endl;
return 42;
}
////////////////////////////////////
test.cpp ////////////////////////////
#include <unistd.h>
#include <iostream>
#include "/soft/BDP/include/corba.h"
#include "/soft/BDP/include/orbtypes.h"
#include "/soft/BDP/include/typecode.h"
#include "testImpl.h"
int main(int argc, char* const* argv)
{
std::cout<<"Start of test..."<<std::endl<<std::endl;
try
{
// implementation
testImpl impl;
// Initialize the ORB.
CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
setDefaultPolicies(orb);
// Get root POA
CORBA::Object_var obj = orb-
>resolve_initial_references("RootPOA");
PortableServer::POA_var rootPOA =
PortableServer::POA::_narrow(obj);
CORBA::Object_ptr p = rootPOA->servant_to_reference(&impl);
CORBA::PolicyList policies;
//policies.length(1);
policies.length(2);
policies[0] = rootPOA-
>create_lifespan_policy(PortableServer::PERSISTENT);
CORBA::Any any;
//any <<= PortableServerExt::BY_POA;
any <<= PortableServerExt::BY_INSTANCE;
policies[1] = orb-
>create_policy(PortableServerExt::BIND_SUPPORT_POLICY_TYPE, any);
rootPOA->the_POAManager()->activate();
// Create myPOA with the right policies
PortableServer::POA_var myPOA = rootPOA->create_POA("testPOA",
rootPOA->the_POAManager(),
policies);
myPOA->the_POAManager()->activate();
CORBA::release(p);
std::cout << "sleep" << std::endl;
sleep(5);
std::cout << "end of sleep" << std::endl;
// Decide on the ID for the servant
PortableServer::ObjectId_var managerId =
PortableServer::string_to_ObjectId("testObj");
// Activate the servant with the ID on myPOA
std::cout<<"Activating server implementation..."<<std::endl;
myPOA->activate_object_with_id(managerId, &impl );
sleep(10);
std::cout<<"Deactivating server implementation..."<<std::endl;
myPOA->deactivate_object(managerId);
sleep(10);
std::cout<<"Destruction of POA..."<<std::endl;
myPOA->destroy(false,true);
std::cout<<"Shutdown of ORB..."<<std::endl;
orb->shutdown(true);
std::cout<<"Destruction of ORB..."<<std::endl;
orb->destroy();
}
catch(const CORBA::Exception& e)
{
std::cerr << "CORBA Exception\n" << std::endl;
return 1;
}
std::cout<<"End of test..."<<std::endl<<std::endl;
return 0;
}