diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-18 04:54:41 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-18 04:54:41 +0000 |
commit | aa42b10d11933f759f80ecfdf22f1a1e87b91a70 (patch) | |
tree | 9d42fa59f3d67e2c1ca726663760c48ffed9e48a | |
parent | 4cf1bdfdb273a0f180528982d80b7bfc32bd0def (diff) | |
download | ATCD-aa42b10d11933f759f80ecfdf22f1a1e87b91a70.tar.gz |
Thu Jun 17 23:43:25 1999 Irfan Pyarali <irfan@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLog-99c | 14 | ||||
-rw-r--r-- | TAO/examples/POA/Adapter_Activator/server.cpp | 53 |
2 files changed, 58 insertions, 9 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c index 6e356a632e9..6ad2198b094 100644 --- a/TAO/ChangeLog-99c +++ b/TAO/ChangeLog-99c @@ -1,3 +1,17 @@ +Thu Jun 17 23:43:25 1999 Irfan Pyarali <irfan@cs.wustl.edu> + + * examples/POA/Adapter_Activator/server.cpp: Fixed servant leak by + reference counting it. + + * examples/POA/Adapter_Activator/run_test.pl + * examples/POA/Explicit_Activation/run_test.pl + * examples/POA/Loader/run_test.pl + * examples/POA/On_Demand_Activation/run_test.pl + * examples/POA/On_Demand_Loading/run_test.pl + + Scripts should create one servant at a time. Otherwise, output + is difficult to read. + Thu Jun 17 22:41:17 1999 Carlos O'Ryan <coryan@cs.wustl.edu> * tao/ORB_Core.h: diff --git a/TAO/examples/POA/Adapter_Activator/server.cpp b/TAO/examples/POA/Adapter_Activator/server.cpp index 66a31b5b079..475b99670df 100644 --- a/TAO/examples/POA/Adapter_Activator/server.cpp +++ b/TAO/examples/POA/Adapter_Activator/server.cpp @@ -27,6 +27,31 @@ ACE_RCSID(Adapter_Activator, server, "$Id$") +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined (_MSC_VER) +# pragma warning (disable : 4250) +#endif /* _MSC_VER */ + +class Reference_Counted_Foo : public virtual PortableServer::RefCountServantBase, + public virtual MyFooServant +{ +public: + Reference_Counted_Foo (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + CORBA::Long value); + // Constructor - takes a POA and a value parameter +}; + +Reference_Counted_Foo::Reference_Counted_Foo (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + CORBA::Long value) + : MyFooServant (orb, + poa, + value) +{ +} + class Adapter_Activator : public POA_PortableServer::AdapterActivator { public: @@ -83,14 +108,19 @@ Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, ACE_TRY_ENV); ACE_CHECK_RETURN (0); - MyFooServant *foo_impl = new MyFooServant (this->orb_.in (), - child.in (), - 28); + Reference_Counted_Foo *foo_impl = new Reference_Counted_Foo (this->orb_.in (), + child.in (), + 28); child->set_servant (foo_impl, ACE_TRY_ENV); ACE_CHECK_RETURN (0); + // This means that the ownership of <foo_impl> now belongs to + // the POA. + foo_impl->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + // Finally everything is fine return 1; } @@ -111,9 +141,9 @@ Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, ACE_CHECK_RETURN (0); } - MyFooServant *foo_impl = new MyFooServant (this->orb_.in (), - child.in (), - 29); + Reference_Counted_Foo *foo_impl = new Reference_Counted_Foo (this->orb_.in (), + child.in (), + 29); PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("third Foo"); @@ -123,6 +153,11 @@ Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, ACE_TRY_ENV); ACE_CHECK_RETURN (0); + // This means that the ownership of <foo_impl> now belongs to + // the POA. + foo_impl->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + // Finally everything is fine return 1; } @@ -339,9 +374,9 @@ main (int argc, char **argv) } // Create a servant. - MyFooServant first_foo_impl (orb.in (), - root_poa.in (), - 27); + Reference_Counted_Foo first_foo_impl (orb.in (), + root_poa.in (), + 27); PortableServer::ObjectId_var first_oid = root_poa->activate_object (&first_foo_impl, |