diff options
author | Phil Mesnier <mesnier_p@ociweb.com> | 2006-04-26 19:08:02 +0000 |
---|---|---|
committer | Phil Mesnier <mesnier_p@ociweb.com> | 2006-04-26 19:08:02 +0000 |
commit | 4d270add1e3ded559c35d3d402a854912abcc43b (patch) | |
tree | a1209e5205b5b574eeeb0d290220a1fda2c1b0cd | |
parent | aeba854a72161e2bdc8303a5501fd531fb824e96 (diff) | |
download | ATCD-4d270add1e3ded559c35d3d402a854912abcc43b.tar.gz |
Wed Apr 26 18:47:23 UTC 2006 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r-- | TAO/ChangeLog | 23 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 69 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 27 | ||||
-rw-r--r-- | TAO/tao/Strategies/OC_Endpoint_Selector_Loader.cpp | 17 | ||||
-rw-r--r-- | TAO/tao/Strategies/OC_Endpoint_Selector_Loader.h | 7 | ||||
-rw-r--r-- | TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp | 2 |
6 files changed, 134 insertions, 11 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 48ecb96913a..f1217fc6245 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,26 @@ +Wed Apr 26 18:47:23 UTC 2006 Phil Mesnier <mesnier_p@ociweb.com> + + * tao/ORB_Core.cpp: + * tao/ORB_Core.h: + + Add an alternate connection timeout hook. This is necessary for + users of the Optimized Connect Endpoint Selector with its + timeout while also using CORBA messaging and the Connection + Timeout policy. Both of these connection timeouts are + dynamically loaded and one would override the other. This change + allows both to be loaded, and if both are initialized to nonzero + values, the lesser of the two timeouts is used. This results + from a bug originally reported to OCI by friedhelm.wolf@homag.de. + + * tao/Strategies/OC_Endpoint_Selector_Loader.cpp: + * tao/Strategies/OC_Endpoint_Selector_Loader.h: + + Cleaned up the initializer to be more consistent with others. + + * tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp: + + Fixed wihtespace in debug output. + Wed Apr 26 16:42:45 UTC 2006 Phil Mesnier <mesnier_p@ociweb.com> * docs/Options.html: diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 7ae1df67ec6..1fbfdc2133a 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -136,7 +136,8 @@ TAO_ORB_Core_Static_Resources::TAO_ORB_Core_Static_Resources (void) iorinterceptor_adapter_factory_name_ ("IORInterceptor_Adapter_Factory"), valuetype_adapter_factory_name_ ("valuetype_Adapter_Factory"), poa_factory_name_ ("TAO_Object_Adapter_Factory"), - poa_factory_directive_ (ACE_TEXT_ALWAYS_CHAR (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", "TAO_PortableServer", "_make_TAO_Object_Adapter_Factory", ""))) + poa_factory_directive_ (ACE_TEXT_ALWAYS_CHAR (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory", "TAO_PortableServer", "_make_TAO_Object_Adapter_Factory", ""))), + alt_connection_timeout_hook_ (0) { } @@ -2823,15 +2824,77 @@ TAO_ORB_Core::call_timeout_hook (TAO_Stub *stub, return; } (*timeout_hook) (this, stub, has_timeout, time_value); + + Timeout_Hook alt_connection_timeout_hook = + TAO_ORB_Core_Static_Resources::instance ()->alt_connection_timeout_hook_; + + if (alt_connection_timeout_hook == 0) + return; + + if (!has_timeout || time_value == ACE_Time_Value::zero ) + { + (*alt_connection_timeout_hook) (this, stub, has_timeout,time_value); + return; + } + + // At this point, both the primary and alternate hooks are defined, and + // the primary did indeed set a value + ACE_Time_Value tv1; + bool ht1; + (*alt_connection_timeout_hook) (this, stub, ht1,tv1); + if (ht1 && tv1 > ACE_Time_Value::zero && tv1 < time_value) + time_value = tv1; } void TAO_ORB_Core::set_timeout_hook (Timeout_Hook hook) { // Saving the hook pointer so that we can use it later when needed. - TAO_ORB_Core_Static_Resources::instance ()->timeout_hook_ = hook; + // For now there are only two entry points that may supply a connection + // timeout hook. But there might be future entry points, so this should + // probably be addressed by a more sophisticated mechanism. + +#define TOCSRi TAO_ORB_Core_Static_Resources::instance () + + // A consern was raised that since this function is called by two + // different initializers there may be a race condition that might + // require a lock. We are not using a lock at this time because of + // two callers, one happens only during service directive processing + // and the other only during ORB Initialization time. The former + // happens when the OC_Endpoint_Selector_Factory is loaded, the + // latter is part of the messaging library. The messaging library + // calls this function as part of pre_init processing, and this call + // happes for every ORB instance. This was the case before these The + // latter call occurs when the messaging library is loaded. The + // redundant calls occured then as well. Second, it isn't clear how + // a lock in this static method would react in the face of windows + // dlls, shared memory segments, etc. Therefore we are continuing to + // keep this code lockless as it always was, assuming no + // simultanious overwrite will occur. + + if (TOCSRi->connection_timeout_hook_ == 0) + { + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("TAO (%P|%t) setting primary hook\n"))); + TOCSRi->connection_timeout_hook_ = hook; + } + else if (TOCSRi->connection_timeout_hook_ != hook && + TOCSRi->alt_connection_timeout_hook_ == 0) + { + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT("TAO (%P|%t) setting alternate hook\n"))); + TOCSRi->alt_connection_timeout_hook_ = hook; + } + else + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) not overwriting alternate hook.") + ACE_TEXT (" Is it still null? %d\n"), + TOCSRi->alt_connection_timeout_hook_ == 0)); - return; +#undef TOCSRi } void diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index d0144373b4b..5b2a3b7a1ae 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -508,6 +508,30 @@ public: ACE_Time_Value &time_value); /// Define the Timeout_Hook signature + /** + * The connection timeout hook was originally defined to allow the + * TAO Messaging code to be factored out of the core TAO library and + * placed in to an optional library. Since then, a new invocation + * endpoint selector, the optimised connection endpoint selector + * (see Strategies/OC_Endpoint_Selector.h) reused this connection + * timeout hook. However, this set up a problem when both the + * Messaging library and OCES are being used in the same + * application. + * + * The solution was to add a new connection timeout hook attribute + * (see alt_connection_timeout_hook_ below). This method now checks + * to see if the connection timeout hook is already set, and if so + * assigns the supplied hook value to the alternate connection + * timeout hook. This functionality has a side-effect of assuming + * that hooks are NEVER unloaded or actively replaced. IOW, no one + * will call this method with a 0 or some other pointer value to + * replace an existing hook. + * + * If such functionality as unloading a hook pointer is required, + * then this method must be extended to give some kind of identity + * for the hook. Additional changes to the definition of the hook + * will also be necessary to support such identity and manipulation. + */ static void connection_timeout_hook (Timeout_Hook hook); void call_sync_scope_hook (TAO_Stub *stub, @@ -1379,6 +1403,9 @@ public: */ ACE_CString poa_factory_directive_; + /// An alternative hook to be set for the ConnectionTimeoutPolicy + TAO_ORB_Core::Timeout_Hook alt_connection_timeout_hook_; + private: /// Constructor. diff --git a/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.cpp b/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.cpp index c250cd76240..314ec97354b 100644 --- a/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.cpp +++ b/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.cpp @@ -1,3 +1,13 @@ +// ================================================================= +/** + * @file OC_Endpoint_Selector_Loader.cpp + * + * $Id$ + * + * @author Phil Mesnier <mesnier_p@ociweb.com> + * + */ +// ================================================================= // $Id$ #include "tao/Strategies/OC_Endpoint_Selector_Loader.h" @@ -9,11 +19,10 @@ ACE_RCSID (tao, TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_OC_Endpoint_Selector_Loader::TAO_OC_Endpoint_Selector_Loader (void) +int +TAO_OC_Endpoint_Selector_Loader::init (void) { -#if defined (TAO_AS_STATIC_LIBS) - ACE_Service_Config::process_directive (ace_svc_desc_TAO_OC_Endpoint_Selector_Factory); -#endif /* TAO_AS_STATIC_LIBS */ + return ACE_Service_Config::process_directive (ace_svc_desc_TAO_OC_Endpoint_Selector_Factory); } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.h b/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.h index 5edc517027d..a19f9cf5b1e 100644 --- a/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.h +++ b/TAO/tao/Strategies/OC_Endpoint_Selector_Loader.h @@ -49,11 +49,12 @@ class TAO_Optimized_Connection_Endpoint_Selector; class TAO_Strategies_Export TAO_OC_Endpoint_Selector_Loader { public: - TAO_OC_Endpoint_Selector_Loader (void); + static int init(void); }; - -static TAO_OC_Endpoint_Selector_Loader _TAO_oc_endpoint_selector_loader; +static int +TAO_Requires_OC_Endpoint_Selector_Loader = + TAO_OC_Endpoint_Selector_Loader::init (); TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp b/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp index dae584e8152..ad864ad1b9f 100644 --- a/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp +++ b/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp @@ -27,7 +27,7 @@ TAO_Optimized_Connection_Endpoint_Selector::TAO_Optimized_Connection_Endpoint_Se if (TAO_debug_level) { ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO(%P|%t) Optimized Connection Enpoint Selector:") + ACE_TEXT ("TAO(%P|%t) Optimized Connection Enpoint Selector: ") ACE_TEXT ("Initializing timeout hook tv = %d sec, %d usec\n"), tv.sec(), tv.usec())); } |