00001 #include "tao/PI_Server/PICurrent_Guard.h" 00002 00003 #if TAO_HAS_INTERCEPTORS == 1 00004 00005 00006 ACE_RCSID (PortableServer, 00007 PICurrent_Guard, 00008 "$Id: PICurrent_Guard.cpp 73264 2006-06-26 09:26:36Z sma $") 00009 00010 00011 #include "tao/ORB_Core.h" 00012 #include "tao/TAO_Server_Request.h" 00013 #include "tao/PI/PICurrent.h" 00014 #include "tao/PI/PICurrent_Impl.h" 00015 00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00017 00018 TAO::PICurrent_Guard::PICurrent_Guard (TAO_ServerRequest &server_request, 00019 bool tsc_to_rsc) 00020 : src_ (0), 00021 dest_ (0) 00022 { 00023 // This constructor is used on the server side. 00024 00025 // Retrieve the thread scope current (no TSS access incurred yet). 00026 CORBA::Object_ptr pi_current_obj = 00027 server_request.orb_core ()->pi_current (); 00028 00029 TAO::PICurrent *pi_current = 00030 dynamic_cast <TAO::PICurrent*> (pi_current_obj); 00031 00032 // If the slot count is zero, there is nothing to copy. Prevent any 00033 // copying (and hence TSS accesses) from occurring. 00034 if (pi_current != 0 && pi_current->slot_count () != 0) 00035 { 00036 // Retrieve the request scope current. 00037 PICurrent_Impl * rsc = server_request.rs_pi_current (); 00038 00039 // Retrieve the thread scope current. 00040 PICurrent_Impl * tsc = pi_current->tsc (); 00041 00042 if (tsc_to_rsc) 00043 { 00044 // TSC to RSC copy. 00045 // Occurs after receive_request() interception point and 00046 // upcall. 00047 this->src_ = tsc; 00048 this->dest_ = rsc; 00049 } 00050 else 00051 { 00052 // RSC to TSC copy. 00053 // Occurs after receive_request_service_contexts() 00054 // interception point. 00055 this->src_ = rsc; 00056 this->dest_ = tsc; 00057 } 00058 } 00059 } 00060 00061 TAO::PICurrent_Guard::~PICurrent_Guard (void) 00062 { 00063 if (this->src_ != 0 && this->dest_ != 0 00064 && this->src_ != this->dest_) 00065 { 00066 this->dest_->take_lazy_copy (this->src_); 00067 } 00068 } 00069 00070 TAO_END_VERSIONED_NAMESPACE_DECL 00071 00072 #endif /* TAO_HAS_INTERCEPTORS == 1 */