From 7495cafc63f30552f774b9b0b2e1a66bb7301707 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Fri, 2 Aug 2002 04:01:40 +0000 Subject: ChangeLogTag:Thu Aug 1 21:00:03 2002 Ossama Othman --- TAO/ChangeLog | 34 ++++++++++ TAO/orbsvcs/orbsvcs/LB_LoadAlert.inl | 7 +-- .../orbsvcs/LoadBalancing/LB_LeastLoaded.cpp | 8 +-- TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h | 8 +-- TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp | 5 +- TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h | 8 +-- TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl | 7 +-- .../LoadBalancing/LB_ServerRequestInterceptor.cpp | 72 ++++++++++++++++++++-- .../LoadBalancing/LB_ServerRequestInterceptor.h | 2 + 9 files changed, 117 insertions(+), 34 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index f0ad58e1886..e82c0a0b7ac 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,37 @@ +Thu Aug 1 21:00:03 2002 Ossama Othman + + * orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.cpp (get_location): + + Corrected LoadManager parameter so that it is not "const." + Fixes an "incompatible qualifier" compile-time error. + + * orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h (enable_alert): + * orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp (enable_alert): + + Corrected object group reference parameter. "CORBA::Object_ptr" + not "CORBA::Object". + + * orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl (forward): + + Removed this method. There is no longer a need to cache a + forward reference. + + * orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.cpp + (receive_request_service_contexts): + + Check for the CosLoadBalancing::LOAD_MANAGED ServiceContext in + the request's ServiceContextList. If it exists, and a load + alert has been enabled, throw a CORBA::TRANSIENT() to force the + client back to the original target, i.e. the LoadManager. + + Do not attempt to obtain the cached forward reference from the + LoadAlert object. It is longer cached. + + * orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h: + * orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h: + + Cosmetic updates. + Thu Aug 1 21:09:22 2002 Balachandran Natarajan * orbsvcs/PSS/PSDL_Node.cpp: Fixed a compile error in Win32 diff --git a/TAO/orbsvcs/orbsvcs/LB_LoadAlert.inl b/TAO/orbsvcs/orbsvcs/LB_LoadAlert.inl index 2099eae3096..37cd8d00e4d 100644 --- a/TAO/orbsvcs/orbsvcs/LB_LoadAlert.inl +++ b/TAO/orbsvcs/orbsvcs/LB_LoadAlert.inl @@ -2,14 +2,9 @@ // // $Id$ + ACE_INLINE CORBA::Boolean TAO_LB_LoadAlert::alerted (void) const { return this->alerted_; } - -ACE_INLINE CORBA::Object_ptr -TAO_LB_LoadAlert::forward (void) -{ - return CORBA::Object::_duplicate (this->forward_.in ()); -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.cpp index 066e05d6f57..34514e3006d 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.cpp @@ -50,7 +50,7 @@ TAO_LB_LeastLoaded::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) { return CORBA::string_dup ("LeastLoaded"); } - + CosLoadBalancing::Properties * TAO_LB_LeastLoaded::get_properties (ACE_ENV_SINGLE_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException)) @@ -67,7 +67,7 @@ TAO_LB_LeastLoaded::get_properties (ACE_ENV_SINGLE_ARG_DECL) return props; } - + void TAO_LB_LeastLoaded::push_loads ( const PortableGroup::Location & the_location, @@ -142,7 +142,7 @@ TAO_LB_LeastLoaded::push_loads ( else { load.id = new_load.id; - load.value = this->effective_load (0, new_load.value); + load.value = this->effective_load (0, new_load.value); } } @@ -197,7 +197,7 @@ TAO_LB_LeastLoaded::next_member ( CORBA::Boolean TAO_LB_LeastLoaded::get_location ( PortableGroup::ObjectGroup_ptr object_group, - const CosLoadBalancing::LoadManager_ptr load_manager, + CosLoadBalancing::LoadManager_ptr load_manager, const PortableGroup::Locations & locations, PortableGroup::Location & location ACE_ENV_ARG_DECL) diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h index 8a30dc47822..f0d62751da8 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LeastLoaded.h @@ -73,17 +73,17 @@ public: //@{ virtual char * name (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - + virtual CosLoadBalancing::Properties * get_properties ( ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - + virtual void push_loads ( const PortableGroup::Location & the_location, const CosLoadBalancing::LoadList & loads ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); - + virtual CORBA::Object_ptr next_member ( PortableGroup::ObjectGroup_ptr object_group, CosLoadBalancing::LoadManager_ptr load_manager @@ -91,7 +91,7 @@ public: ACE_THROW_SPEC ((CORBA::SystemException, PortableGroup::ObjectGroupNotFound, PortableGroup::MemberNotFound)); - + // virtual void analyze_loads ( // PortableGroup::ObjectGroup_ptr object_group, // CosLoadBalancing::LoadManager_ptr load_manager diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp index 2dd62eec303..1141e4637a5 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.cpp @@ -10,8 +10,7 @@ ACE_RCSID (LoadBalancer, #endif /* __ACE_INLINE__ */ TAO_LB_LoadAlert::TAO_LB_LoadAlert (void) - : alerted_ (0), - forward_ () + : alerted_ (0) { } @@ -20,7 +19,7 @@ TAO_LB_LoadAlert::~TAO_LB_LoadAlert (void) } void -TAO_LB_LoadAlert::enable_alert (CORBA::Object /* object_group */ +TAO_LB_LoadAlert::enable_alert (CORBA::Object_ptr /* object_group */ ACE_ENV_ARG_DECL_NOT_USED) ACE_THROW_SPEC ((CORBA::SystemException)) { diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h index 0f8001ec47d..9140f5a9f24 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.h @@ -43,7 +43,7 @@ public: /// Forward requests back to the load manager via the object group /// reference. - virtual void enable_alert (CORBA::Object object_group + virtual void enable_alert (CORBA::Object_ptr object_group ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((CORBA::SystemException)); @@ -57,8 +57,6 @@ public: /// by the LoadManager. CORBA::Boolean alerted (void) const; - CORBA::Object_ptr forward (void); - protected: /// Destructor. @@ -74,10 +72,6 @@ private: /// by the LoadManager? CORBA::Boolean alerted_; - /// Reference to the object which clients will be forwarded to if an - /// "alert" condition exists. - CORBA::Object_var forward_; - }; diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl index 2099eae3096..37cd8d00e4d 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_LoadAlert.inl @@ -2,14 +2,9 @@ // // $Id$ + ACE_INLINE CORBA::Boolean TAO_LB_LoadAlert::alerted (void) const { return this->alerted_; } - -ACE_INLINE CORBA::Object_ptr -TAO_LB_LoadAlert::forward (void) -{ - return CORBA::Object::_duplicate (this->forward_.in ()); -} diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.cpp b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.cpp index 62a584bd13e..c0bfbe9e34a 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.cpp +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.cpp @@ -34,16 +34,71 @@ TAO_LB_ServerRequestInterceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) void TAO_LB_ServerRequestInterceptor::receive_request_service_contexts ( - PortableInterceptor::ServerRequestInfo_ptr /* ri */ + PortableInterceptor::ServerRequestInfo_ptr ri ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::ForwardRequest)) { if (this->load_alert_.alerted ()) { - CORBA::Object_var forward = this->load_alert_.forward (); - - ACE_THROW (PortableInterceptor::ForwardRequest (forward.in (), 0)); + ACE_TRY + { + IOP::ServiceContext_var service_context = + ri->get_request_service_context (CosLoadBalancing::LOAD_MANAGED + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + /* + // Use TAO-specific "compiled marshaling" instead of + // standard interpretive marshaling via a CDR encapsulation + // Codec for efficiency reasons. + const char * buf = + ACE_reinterpret_cast (const char *, + service_context->context_data.get_buffer ()); + TAO_InputCDR cdr (buf, + service_context->context_data.length ()); + + CORBA::Boolean byte_order; + if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + ACE_THROW (CORBA::BAD_PARAM ()); + + cdr.reset_byte_order (ACE_static_cast (int, byte_order)); + + CORBA::Object_var object_group; + if (cdr >> object_group.out ()) + ACE_THROW (PortableInterceptor::ForwardRequest (object_group.in (), + 0)); + else + ACE_THROW (CORBA::BAD_PARAM ()); + */ + + // A ServiceContext of the given ServiceId exists. This + // means that the target is load balanced. Force the client + // to try another profile since this location is currently + // overloaded. + ACE_THROW (CORBA::TRANSIENT ()); + } + ACE_CATCH (CORBA::BAD_PARAM, ex) + { + // No CosLoadBalancing::LB_GROUP_REF ServiceContext. This + // probably means that the target object is not + // LoadBalanced. + + // There is a huge DoS attack vulnerability with this load + // shedding model. The model relies on the client behaving + // correctly. In particular, it relies on the client to + // send the forward object group reference in the + // ServiceContextList. Any "misbehaving" client can avoid + // that, in which case no load will ever be shed! + + + // Make sure we get a CORBA::BAD_PARAM for the right + // reason. + if (ex.minor () != TAO_OMG_VMCID | 26) + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; } } @@ -71,6 +126,15 @@ TAO_LB_ServerRequestInterceptor::send_exception ( ACE_THROW_SPEC ((CORBA::SystemException, PortableInterceptor::ForwardRequest)) { + if (TAO_debug_level > 0) + { + // A CORBA::TRANSIENT is thrown when the LoadManager informs the + // LoadAlert object that its member is overloaded, for example. + + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("TAO_LB_ServerRequestInterceptor -- ") + ACE_TEXT ("Exception thrown.\n"))); + } } void diff --git a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h index a9c18bb091f..fd0e3e937f1 100644 --- a/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h +++ b/TAO/orbsvcs/orbsvcs/LoadBalancing/LB_ServerRequestInterceptor.h @@ -10,6 +10,7 @@ */ //============================================================================= + #ifndef TAO_LB_SERVER_REQUEST_INTERCEPTOR_H #define TAO_LB_SERVER_REQUEST_INTERCEPTOR_H @@ -113,4 +114,5 @@ private: #pragma warning(pop) #endif /* _MSC_VER */ + #endif /* TAO_LB_SERVER_REQUEST_INTERCEPTOR_H */ -- cgit v1.2.1