[tao-users] Singleton CORBA object
Siddharth Kulkarni
sidd.kulkarni at gmail.com
Tue Sep 29 06:01:21 CDT 2015
Hi!
Following is the psuedo code
//MainCORBAImpl.h
class CMainCORBAImpl
{
public:
XServicePtr GetXService();
private:
XServicePtr m_XSvc;
PortableServer::servant_var<Servant> m_pServant;
};
//MainCORBAImpl.cpp
XServicePtr CMainCORBAImpl::GetXService()
{
try
{
if(m_pServant== nullptr)
{
m_pServant= create_servant();
PortableServer::ObjectId *oid =
m_poa->activate_object(m_pServant.in()); // ref count=2
CORBA::Object_ptr retobj = m_poa->id_to_reference(*oid);
m_XSvc= ::XService::_narrow(retobj);
m_pServant->_remove_ref();
if (::CORBA::is_nil(m_XSvc))
{
//throw exception
}
}
}
catch(...)
{
//throw exception
}
return m_XSvc;
}
The multiple calls to GetXService() is causing crash. The debugger points
to the following CORBA skeleton code
template<typename S_ptr,
typename S_var,
class Insert_Policy>
CORBA::Boolean
TAO::Ret_Object_SArgument_T<S_ptr,S_var,Insert_Policy>::marshal
(TAO_OutputCDR &cdr)
{
return cdr << this->x_.in ();
}
Thanks & Regards
Siddharth
On Tue, Sep 29, 2015 at 3:58 PM, Christian Fromme <christian at ast.dfs.de>
wrote:
> On 29.09. 15:22, Siddharth Kulkarni wrote:
> > I am using ACE/TAO and having a general question regarding CORBA.
> > I am facing the scenario where the CORBA server need to return same CORBA
> > object again and again. I am facing server crash while returning the
> object
> > after two to three times.
> > I am creating and activating the object once and keep in memory. Then
> upon
> > client request returning the same object. Hence it is kind of singleton
> > object.
> > Can anybody suggest whether the given strategy is wrong? Then what is the
> > correct strategy in this scenario.
>
> How exactly are you returning the object? (IDL and implementation code)
>
> Best,
> Christian
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.isis.vanderbilt.edu/pipermail/tao-users/attachments/20150929/8dc08ce1/attachment.html>
More information about the tao-users
mailing list