diff options
author | naga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-02 04:25:14 +0000 |
---|---|---|
committer | naga <naga@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-02 04:25:14 +0000 |
commit | 6519d7fd4ae6c6586d0af8d095d9cce7dfac995b (patch) | |
tree | 600bd3adfdaf9924b60fbd2ec764e7484b2f5090 | |
parent | 9c638d6e95e6d9f213c851f788ca987ecaee2fea (diff) | |
download | ATCD-6519d7fd4ae6c6586d0af8d095d9cce7dfac995b.tar.gz |
Added the correct implementation of destroy method according to Irfan's suggestion.
Also corrected some TAO_ macros used for exceptions.
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp | 103 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h | 48 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.cpp | 22 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.h | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp | 263 |
5 files changed, 288 insertions, 152 deletions
diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp index a0b3de34a78..cb4702efe76 100644 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp +++ b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.cpp @@ -85,51 +85,42 @@ TAO_Basic_StreamCtrl::destroy (const AVStreams::flowSpec &the_spec, // Changes the QoS associated with the stream // Empty the_spec means apply operation to all flows CORBA::Boolean -TAO_Basic_StreamCtrl::modify_QoS (AVStreams::streamQoS &new_qos, - const AVStreams::flowSpec &the_spec, - CORBA::Environment &ACE_TRY_ENV) +TAO_Basic_StreamCtrl::modify_QoS (AVStreams::streamQoS &/*new_qos*/, + const AVStreams::flowSpec &/*the_spec*/, + CORBA::Environment &/*ACE_TRY_ENV*/) { - ACE_UNUSED_ARG (new_qos); - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (ACE_TRY_ENV); return 0; } // Used by StreamEndPoint and VDev to inform StreamCtrl of events. // E.g., loss of flow, reestablishment of flow, etc.. void -TAO_Basic_StreamCtrl::push_event (const struct CosPropertyService::Property & the_event, - CORBA::Environment &ACE_TRY_ENV) +TAO_Basic_StreamCtrl::push_event (const struct CosPropertyService::Property &/*the_event*/, + CORBA::Environment &/*ACE_TRY_ENV*/) { - ACE_DEBUG ((LM_DEBUG, - "\n(%P|%t) Recieved event \"")); - ACE_UNUSED_ARG (the_event); - ACE_UNUSED_ARG (ACE_TRY_ENV); + ACE_DEBUG ((LM_DEBUG,"\n(%P|%t) Recieved event \"")); } // @@ Need to throw not-supported exception here void -TAO_Basic_StreamCtrl::set_FPStatus (const AVStreams::flowSpec &the_spec, - const char *fp_name, - const CORBA::Any &fp_settings, - CORBA::Environment &ACE_TRY_ENV) +TAO_Basic_StreamCtrl::set_FPStatus (const AVStreams::flowSpec &/*the_spec*/, + const char */*fp_name*/, + const CORBA::Any &/*fp_settings*/, + CORBA::Environment &/*ACE_TRY_ENV*/) { - ACE_UNUSED_ARG (the_spec); - ACE_UNUSED_ARG (fp_name); - ACE_UNUSED_ARG (fp_settings); - ACE_UNUSED_ARG (ACE_TRY_ENV); } // @@ Need to throw not-supported exception here CORBA::Object_ptr TAO_Basic_StreamCtrl::get_flow_connection (const char *flow_name, - CORBA::Environment &) + CORBA::Environment &ACE_TRY_ENV) { TAO_String_Hash_Key flow_name_key (flow_name); FlowConnection_Map::ENTRY *flow_connection_entry = 0; if (this->flow_map_.find (flow_name_key,flow_connection_entry) == 0) return flow_connection_entry->int_id_; - return 0; + else + ACE_THROW_RETURN (AVStreams::noSuchFlow (),CORBA::Object::_nil ()); } // @@ Need to throw not-supported exception here @@ -1023,9 +1014,20 @@ TAO_MMDevice::destroy (AVStreams::StreamEndPoint_ptr the_ep, const char *vdev_name, CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (vdev_name); - ACE_UNUSED_ARG (ACE_TRY_ENV); + // Remove self from POA. Because of reference counting, the POA + // will automatically delete the servant when all pending requests + // on this servant are complete. + // + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; } // Adds the fdev object to the MMDevice. @@ -1164,7 +1166,20 @@ TAO_FlowConnection::start (CORBA::Environment &ACE_TRY_ENV) void TAO_FlowConnection::destroy (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (ACE_TRY_ENV); + // Remove self from POA. Because of reference counting, the POA + // will automatically delete the servant when all pending requests + // on this servant are complete. + // + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; } // modify the QoS for this flow. @@ -1340,7 +1355,20 @@ TAO_FlowEndPoint::start (CORBA::Environment &ACE_TRY_ENV) void TAO_FlowEndPoint::destroy (CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (ACE_TRY_ENV); + // Remove self from POA. Because of reference counting, the POA + // will automatically delete the servant when all pending requests + // on this servant are complete. + // + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; } AVStreams::StreamEndPoint_ptr @@ -1808,13 +1836,24 @@ TAO_FDev::bind_mcast (AVStreams::FDev_ptr first_peer, } void -TAO_FDev::destroy (AVStreams::FlowEndPoint_ptr the_ep, - const char * fdev_name, +TAO_FDev::destroy (AVStreams::FlowEndPoint_ptr /*the_ep*/, + const char * /*fdev_name*/, CORBA::Environment &ACE_TRY_ENV) { - ACE_UNUSED_ARG (the_ep); - ACE_UNUSED_ARG (fdev_name); - ACE_UNUSED_ARG (ACE_TRY_ENV); + // Remove self from POA. Because of reference counting, the POA + // will automatically delete the servant when all pending requests + // on this servant are complete. + // + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h index 617992d918b..9f9c4eb991a 100644 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h +++ b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i.h @@ -36,7 +36,9 @@ #include "orbsvcs/Trader/Trader.h" // for the Hash_Map helper classes. -class TAO_ORBSVCS_Export AV_Null_MediaCtrl : public virtual POA_Null_MediaCtrl +class TAO_ORBSVCS_Export AV_Null_MediaCtrl + : public virtual POA_Null_MediaCtrl, + public virtual PortableServer::RefCountServantBase { public: AV_Null_MediaCtrl (void); @@ -45,7 +47,8 @@ class TAO_ORBSVCS_Export AV_Null_MediaCtrl : public virtual POA_Null_MediaCtrl class TAO_ORBSVCS_Export TAO_Basic_StreamCtrl : public virtual POA_AVStreams::Basic_StreamCtrl, - public virtual TAO_PropertySet<POA_AVStreams::Basic_StreamCtrl> + public virtual TAO_PropertySet<POA_AVStreams::Basic_StreamCtrl>, + public virtual PortableServer::RefCountServantBase // = DESCRIPTION // Base class for StreamCtrl, implements basic stream start // and stop functionality @@ -122,7 +125,8 @@ class TAO_ORBSVCS_Export TAO_Basic_StreamCtrl }; class TAO_ORBSVCS_Export TAO_Negotiator - : public POA_AVStreams::Negotiator + : public POA_AVStreams::Negotiator, + public virtual PortableServer::RefCountServantBase { public: virtual CORBA::Boolean negotiate (AVStreams::Negotiator_ptr remote_negotiator, @@ -134,7 +138,8 @@ class TAO_MCastConfigIf; class TAO_ORBSVCS_Export TAO_StreamCtrl : public virtual POA_AVStreams::StreamCtrl, - public virtual TAO_Basic_StreamCtrl + public virtual TAO_Basic_StreamCtrl, + public virtual PortableServer::RefCountServantBase // = DESCRIPTION // Implementation the A/V StreamCtrl class. this class // is used to control the stream. It should be subclassed @@ -182,7 +187,8 @@ private: class TAO_ORBSVCS_Export TAO_MCastConfigIf : public virtual POA_AVStreams::MCastConfigIf, - public virtual TAO_PropertySet<POA_AVStreams::MCastConfigIf> + public virtual TAO_PropertySet<POA_AVStreams::MCastConfigIf>, + public virtual PortableServer::RefCountServantBase { public: virtual CORBA::Boolean set_peer (CORBA::Object_ptr peer, @@ -262,7 +268,8 @@ public: class TAO_ORBSVCS_Export TAO_Client_StreamEndPoint : public virtual TAO_StreamEndPoint<POA_AVStreams::StreamEndPoint_A>, - public virtual TAO_Client_Base_StreamEndPoint + public virtual TAO_Client_Base_StreamEndPoint, + public virtual PortableServer::RefCountServantBase { // = DESCRIPTION // The "A" side of a streamendpoint @@ -300,7 +307,8 @@ public: class TAO_ORBSVCS_Export TAO_Server_StreamEndPoint : public virtual POA_AVStreams::StreamEndPoint_B, public virtual TAO_StreamEndPoint<POA_AVStreams::StreamEndPoint_B>, - public virtual TAO_Server_Base_StreamEndPoint // Abstract interface + public virtual TAO_Server_Base_StreamEndPoint,// Abstract interface + public virtual PortableServer::RefCountServantBase { // = DESCRIPTION // The "B" side of a streamendpoint @@ -332,7 +340,8 @@ public: class TAO_ORBSVCS_Export TAO_VDev :public virtual TAO_PropertySet<POA_AVStreams::VDev>, - public virtual POA_AVStreams::VDev + public virtual POA_AVStreams::VDev, + public virtual PortableServer::RefCountServantBase // = DESCRIPTION // Implements the VDev interface. One of these is created per connection, // and represents device-specific parameters @@ -393,8 +402,8 @@ class TAO_AV_Endpoint_Strategy; class TAO_ORBSVCS_Export TAO_MMDevice :public virtual POA_AVStreams::MMDevice, - public TAO_PropertySet<POA_AVStreams::MMDevice> - + public TAO_PropertySet<POA_AVStreams::MMDevice>, + public virtual PortableServer::RefCountServantBase // = DESCRIPTION // Implements a factory to create Endpoints and VDevs { @@ -480,8 +489,8 @@ class TAO_FlowProducer; class TAO_ORBSVCS_Export TAO_FlowConnection : public virtual POA_AVStreams::FlowConnection, - public TAO_PropertySet<POA_AVStreams::FlowConnection> - + public TAO_PropertySet<POA_AVStreams::FlowConnection>, + public virtual PortableServer::RefCountServantBase { // =TITLE // Class to manage a flow connection. @@ -556,7 +565,8 @@ private: class TAO_ORBSVCS_Export TAO_FlowEndPoint : public virtual POA_AVStreams::FlowEndPoint, - public virtual TAO_PropertySet<POA_AVStreams::FlowEndPoint> + public virtual TAO_PropertySet<POA_AVStreams::FlowEndPoint>, + public virtual PortableServer::RefCountServantBase { // = DESCRIPTION // This class is used per flow e.g video flow and an audio flow @@ -657,7 +667,8 @@ private: class TAO_ORBSVCS_Export TAO_FlowProducer: public virtual POA_AVStreams::FlowProducer, - public virtual TAO_FlowEndPoint + public virtual TAO_FlowEndPoint, + public virtual PortableServer::RefCountServantBase { public: TAO_FlowProducer (void); @@ -708,7 +719,8 @@ class TAO_ORBSVCS_Export TAO_FlowProducer: class TAO_ORBSVCS_Export TAO_FlowConsumer : public virtual POA_AVStreams::FlowConsumer, - public virtual TAO_FlowEndPoint + public virtual TAO_FlowEndPoint, + public virtual PortableServer::RefCountServantBase { public: TAO_FlowConsumer (void); @@ -737,7 +749,8 @@ class TAO_ORBSVCS_Export TAO_FlowConsumer : class TAO_ORBSVCS_Export TAO_FDev : public virtual POA_AVStreams::FDev, - public virtual TAO_PropertySet<POA_AVStreams::FDev> + public virtual TAO_PropertySet<POA_AVStreams::FDev>, + public virtual PortableServer::RefCountServantBase { public: TAO_FDev (void); @@ -798,7 +811,8 @@ class TAO_ORBSVCS_Export TAO_FDev : }; class TAO_ORBSVCS_Export TAO_MediaControl - :public virtual POA_AVStreams::MediaControl + :public virtual POA_AVStreams::MediaControl, + public virtual PortableServer::RefCountServantBase { // = TITLE // Abstract Mediacontrol class. diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.cpp b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.cpp index c14563b8614..64f8fb3cf7c 100644 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.cpp +++ b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.cpp @@ -43,11 +43,27 @@ TAO_StreamEndPoint<IF>::start (const AVStreams::flowSpec &flow_spec, template <class IF> void TAO_StreamEndPoint<IF>::destroy (const AVStreams::flowSpec &the_spec, - CORBA::Environment &ACE_TRY_ENV) + CORBA::Environment &ACE_TRY_ENV) { - // Make the upcall into the app - this->handle_destroy (the_spec, ACE_TRY_ENV); +// // Make the upcall into the app +// this->handle_destroy (the_spec, ACE_TRY_ENV); + // + // Remove self from POA. Because of reference counting, the POA + // will automatically delete the servant when all pending requests + // on this servant are complete. + // + PortableServer::POA_var poa = this->_default_POA (ACE_TRY_ENV); + ACE_CHECK; + + PortableServer::ObjectId_var id = poa->servant_to_id (this, + ACE_TRY_ENV); + ACE_CHECK; + + poa->deactivate_object (id.in (), + ACE_TRY_ENV); + ACE_CHECK; } + // Called by our peer endpoint, requesting us to establish // a connection template <class IF> diff --git a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.h b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.h index b7efc1415a4..90addb24e28 100644 --- a/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.h +++ b/TAO/orbsvcs/orbsvcs/AV/AVStreams_i_T.h @@ -6,7 +6,8 @@ template <class IF> class TAO_ORBSVCS_Export TAO_StreamEndPoint : public virtual TAO_Base_StreamEndPoint, - public virtual TAO_PropertySet<IF> + public virtual TAO_PropertySet<IF>, + public virtual PortableServer::RefCountServantBase { // = DESCRIPTION // The Stream EndPoint. Used to implement one endpoint of a stream @@ -27,7 +28,6 @@ public: CORBA::Environment &env = CORBA::Environment::default_environment ()); // Destroy the stream, Empty the_spec means, for all the flows - virtual CORBA::Boolean connect (AVStreams::StreamEndPoint_ptr responder, AVStreams::streamQoS &qos_spec, const AVStreams::flowSpec &the_spec, diff --git a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp index d0888b681a7..c9e772a1246 100644 --- a/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp +++ b/TAO/orbsvcs/orbsvcs/AV/Endpoint_Strategy_T.cpp @@ -26,6 +26,7 @@ template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> int TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate (void) { + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { this->activate_stream_endpoint (ACE_TRY_ENV); @@ -46,6 +47,7 @@ TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activ return -1; } ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; } @@ -61,9 +63,9 @@ TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activ if (this->make_vdev (vdev) == -1) return -1; - // Put the object in the POA + // Activate the object under the root poa. CORBA::String_var vdev_ior = this->orb_manager_->activate (vdev, - env); + ACE_TRY_ENV); ACE_TRY_CHECK; ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Endpoint_Reactive_Strategy::activate_vdev, vdev ior is:%s\n", vdev_ior. in ())); @@ -71,6 +73,8 @@ TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activ // Save the object reference, so that create_A can return it this->vdev_ = vdev->_this (ACE_TRY_ENV); ACE_TRY_CHECK; + vdev->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; } ACE_CATCHANY { @@ -94,7 +98,7 @@ TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activ if (this->make_mediactrl (media_ctrl) == -1) return -1; - // Put the object in the POA + // Activate the mediactrl object under the root poa. CORBA::String_var mediactrl_ior = this->orb_manager_->activate (media_ctrl, ACE_TRY_ENV); ACE_TRY_CHECK; @@ -104,7 +108,7 @@ TAO_AV_Endpoint_Reactive_Strategy <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activ // Associate the media controller object reference with the vdev, as per the OMG spec CORBA::Any anyval; - anyval <<= this->orb_manager_->orb ()->object_to_string (media_ctrl->_this (env), + anyval <<= this->orb_manager_->orb ()->object_to_string (media_ctrl->_this (ACE_TRY_ENV), ACE_TRY_ENV); ACE_TRY_CHECK; @@ -215,6 +219,8 @@ TAO_AV_Endpoint_Reactive_Strategy_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::act // Save the object references, so that create_a can return them this->stream_endpoint_a_ = stream_endpoint_a->_this (ACE_TRY_ENV); ACE_TRY_CHECK; + stream_endpoint_a->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; } ACE_CATCHANY { @@ -261,6 +267,8 @@ TAO_AV_Endpoint_Reactive_Strategy_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::act this->stream_endpoint_b_ = stream_endpoint_b->_this (ACE_TRY_ENV); ACE_TRY_CHECK; + stream_endpoint_b->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; } ACE_CATCHANY { @@ -312,6 +320,7 @@ template <class T_StreamEndpoint_B, class T_VDev , class T_MediaCtrl> int TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::init (int argc, char **argv) { + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { // create the objects and activate them in the poa @@ -355,45 +364,53 @@ TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::activate_objects char **argv, CORBA::Environment &ACE_TRY_ENV) { - // initialize the orb - this->orb_manager_.init (argc, - argv, - ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, -1); - - // bridge method to make a new stream endpoint - if (this->make_stream_endpoint (this->stream_endpoint_) == -1) - return -1; + ACE_TRY + { + // initialize the orb + this->orb_manager_.init (argc, + argv, + ACE_TRY_ENV); + ACE_TRY_CHECK; - // bridge method to make a new vdev - if (this->make_vdev (this->vdev_) == -1) - return -1; + // bridge method to make a new stream endpoint + if (this->make_stream_endpoint (this->stream_endpoint_) == -1) + return -1; - // bridge method to make a new media controller - if (this->make_mediactrl (this->media_ctrl_) == -1) - return -1; + // bridge method to make a new vdev + if (this->make_vdev (this->vdev_) == -1) + return -1; - // activate the stream_endpoint - CORBA::String_var stream_endpoint_ior = this->orb_manager_.activate (this->stream_endpoint_, - ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,stream_endpoint_ior :%s\n",stream_endpoint_ior.in ())); + // bridge method to make a new media controller + if (this->make_mediactrl (this->media_ctrl_) == -1) + return -1; - // activate the vdev - CORBA::String_var vdev_ior = this->orb_manager_.activate (this->vdev_, - ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects, vdev ior is :%s\n",vdev_ior.in ())); + // activate the stream_endpoint + CORBA::String_var stream_endpoint_ior = this->orb_manager_.activate (this->stream_endpoint_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,stream_endpoint_ior :%s\n",stream_endpoint_ior.in ())); - // activate the media controller - CORBA::String_var media_ctrl_ior = this->orb_manager_.activate (this->media_ctrl_, - ACE_TRY_ENV); + // activate the vdev + CORBA::String_var vdev_ior = this->orb_manager_.activate (this->vdev_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects, vdev ior is :%s\n",vdev_ior.in ())); - TAO_CHECK_ENV_RETURN (env, -1); - ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,media_ctrl_ior is: %s\n",media_ctrl_ior.in ())); + // activate the media controller + CORBA::String_var media_ctrl_ior = this->orb_manager_.activate (this->media_ctrl_, + ACE_TRY_ENV); + ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG,"(%P|%t)TAO_AV_Child_Process::activate_objects,media_ctrl_ior is: %s\n",media_ctrl_ior.in ())); + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_AV_Child_Process::init "); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; - } // Bind to the namingservice @@ -401,19 +418,27 @@ template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> int TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::bind_to_naming_service (CORBA::Environment &ACE_TRY_ENV) { - CORBA::Object_var naming_obj = - this->orb_manager_.orb ()->resolve_initial_references ("NameService"); - if (CORBA::is_nil (naming_obj.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - " (%P|%t) Unable to resolve the Name Service.\n"), - -1); - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); - this->naming_context_ = - CosNaming::NamingContext::_narrow (naming_obj.in (), - ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, - -1); - + ACE_TRY + { + CORBA::Object_var naming_obj = + this->orb_manager_.orb ()->resolve_initial_references ("NameService"); + if (CORBA::is_nil (naming_obj.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to resolve the Name Service.\n"), + -1); + // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); + this->naming_context_ = + CosNaming::NamingContext::_narrow (naming_obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_AV_Child_Process::bind_to_naming_service"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; } @@ -422,43 +447,70 @@ template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> int TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::register_vdev (CORBA::Environment &ACE_TRY_ENV) { - char vdev_name [BUFSIZ]; - ACE_OS::sprintf (vdev_name, - "%s:%s:%d", - "VDev", - this->host_, - this->pid_); - - ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",vdev_name)); - // create the name - this->vdev_name_.length (1); - this->vdev_name_ [0].id = CORBA::string_dup (vdev_name); - - // make the media controller a property of the vdev - CORBA::Any media_ctrl_property; - media_ctrl_property <<= this->orb_manager_.orb ()->object_to_string (this->media_ctrl_->_this (env), - ACE_TRY_ENV); - this->vdev_->define_property ("Related_MediaCtrl", - media_ctrl_property, - ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env,-1); - - // Register the vdev with the naming server. - this->naming_context_->bind (this->vdev_name_, - this->vdev_->_this (env), - ACE_TRY_ENV); + CORBA::Object_ptr vdev_obj; + ACE_TRY + { + char vdev_name [BUFSIZ]; + ACE_OS::sprintf (vdev_name, + "%s:%s:%d", + "VDev", + this->host_, + this->pid_); + + ACE_DEBUG ((LM_DEBUG,"(%P|%t)%s\n",vdev_name)); + // create the name + this->vdev_name_.length (1); + this->vdev_name_ [0].id = CORBA::string_dup (vdev_name); + + // make the media controller a property of the vdev + CORBA::Any media_ctrl_property; + CORBA::Object_var media_ctrl_obj = + this->media_ctrl_->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + media_ctrl_property <<= this->orb_manager_.orb ()->object_to_string (media_ctrl_obj.in (), + ACE_TRY_ENV); + ACE_TRY_CHECK; + this->vdev_->define_property ("Related_MediaCtrl", + media_ctrl_property, + ACE_TRY_ENV); + ACE_TRY_CHECK; - // If the object was already there, replace the older reference - // with this one - if (env.exception () != 0) + vdev_obj = this->vdev_->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + this->vdev_->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCHANY { - env.clear (); + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_AV_Child_Process::register_vdev"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); + ACE_TRY_EX (bind) + { + // Register the vdev with the naming server. + this->naming_context_->bind (this->vdev_name_, + vdev_obj, + ACE_TRY_ENV); + ACE_TRY_CHECK_EX (bind); + } + ACE_CATCH (CosNaming::NamingContext::AlreadyBound,ex) + { + // If the object was already there, replace the older reference + // with this one this->naming_context_->rebind (this->vdev_name_, - this->vdev_->_this (env), + vdev_obj, ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, -1); + ACE_TRY_CHECK; } - + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_AV_Child_Process::register_vdev"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; } @@ -468,6 +520,7 @@ int TAO_AV_Child_Process <T_StreamEndpoint_B, T_VDev, T_MediaCtrl>::run (ACE_Time_Value *tv) { int result; + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { result = this->orb_manager_.run (ACE_TRY_ENV,tv); @@ -519,24 +572,37 @@ template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> int TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::register_stream_endpoint (CORBA::Environment &ACE_TRY_ENV) { - // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); - // Create a name for the video control object - // subclasses can define their own name for the streamendpoint - // Register the stream endpoint object with the naming server. - this->naming_context_->bind (this->stream_endpoint_name_, - this->stream_endpoint_->_this (env), - ACE_TRY_ENV); - - // if the name was already there, replace the reference with the new one - if (env.exception () != 0) + CORBA::Object_ptr stream_endpoint_obj = CORBA::Object::_nil (); + ACE_TRY { - env.clear (); + stream_endpoint_obj = this->stream_endpoint_->_this (ACE_TRY_ENV); + ACE_TRY_CHECK; + this->stream_endpoint_->_remove_ref (ACE_TRY_ENV); + ACE_TRY_CHECK; + // ACE_DEBUG ((LM_DEBUG, "(%P|%t) %s:%d\n", __FILE__, __LINE__)); + // Create a name for the video control object + // subclasses can define their own name for the streamendpoint + // Register the stream endpoint object with the naming server. + this->naming_context_->bind (this->stream_endpoint_name_, + stream_endpoint_obj, + ACE_TRY_ENV); + ACE_TRY_CHECK; + } + ACE_CATCH (CosNaming::NamingContext::AlreadyBound,ex) + { + // if the name was already there, replace the reference with the new one this->naming_context_->rebind (this->stream_endpoint_name_, - this->stream_endpoint_->_this (env), + stream_endpoint_obj, ACE_TRY_ENV); - TAO_CHECK_ENV_RETURN (env, -1); + ACE_TRY_CHECK; } - + ACE_CATCHANY + { + ACE_TRY_ENV.print_exception ("TAO_Endpoint_Reactive_Strategy::activate"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); return 0; } @@ -580,11 +646,12 @@ TAO_AV_Child_Process<T_StreamEndpoint, T_VDev, T_MediaCtrl>::make_mediactrl (T_M // For now, we dont delete the objects, since they exist for the // lifetime of the process anyway template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process () +TAO_AV_Child_Process<T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process () { // Remove the names from the naming service if (CORBA::is_nil (this->naming_context_.in ()) == 0) return; + ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { this->naming_context_->unbind (this->stream_endpoint_name_, @@ -616,7 +683,7 @@ TAO_AV_Child_Process <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Pro // Define the name of the stream_endpoint, as used to register with // the naming service template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_A () +TAO_AV_Child_Process_A<T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_A () { char stream_endpoint_name[BUFSIZ]; ACE_OS::sprintf (stream_endpoint_name, @@ -642,7 +709,7 @@ TAO_AV_Child_Process_A <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_P // Define the name of the stream_endpoint, as used to register with // the naming service template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_B () +TAO_AV_Child_Process_B<T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Process_B () { char stream_endpoint_name[BUFSIZ]; ACE_OS::sprintf (stream_endpoint_name, @@ -657,7 +724,7 @@ TAO_AV_Child_Process_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::TAO_AV_Child_Pr } template <class T_StreamEndpoint, class T_VDev , class T_MediaCtrl> -TAO_AV_Child_Process_B <T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process_B () +TAO_AV_Child_Process_B<T_StreamEndpoint, T_VDev, T_MediaCtrl>::~TAO_AV_Child_Process_B () { } |