diff options
author | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-18 23:53:02 +0000 |
---|---|---|
committer | iliyan <iliyan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2006-09-18 23:53:02 +0000 |
commit | 87b31ac9d2890f65e4203ab8adbf9d8b1ead6f86 (patch) | |
tree | 240eebeb2c29884076a28b30e0b387e4ec308d96 /TAO | |
parent | f356e808764e5f31a3266d9b5e7fdc73aba3082f (diff) | |
download | ATCD-87b31ac9d2890f65e4203ab8adbf9d8b1ead6f86.tar.gz |
ChangeLogTag: Mon Sep 18 23:11:31 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com>
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog | 26 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 3 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 2 | ||||
-rw-r--r-- | TAO/tao/default_resource.cpp | 156 | ||||
-rw-r--r-- | TAO/tao/default_resource.h | 60 |
5 files changed, 184 insertions, 63 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 7b34ae7d764..a6443981a08 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,29 @@ +Mon Sep 18 23:11:31 UTC 2006 Iliyan Jeliazkov <iliyan@ociweb.com> + + This change fixes bug#2651, related to the order of destruction + of Codeset Manager instances, owned by the Default Resource + Factory. It is a prerequisite for correctly fixing bug#2612 and + also fixes a design artifact left over from the splitting of the + codesets in their own library. See the bugzilla entry for more + details. + + * tao/ORB_Core.h: + * tao/ORB_Core.cpp: + + The Core is now responsible for managing the life-cycle of the + Codeset Manager instance, instead of the Resource Factory. + + * tao/default_resource.h: + * tao/default_resource.cpp: + + Introducing a TAO_Codeset_Parameters class, which encapsulates + codeset configuration information. Keeping the configuration + information instead of the configured instance, allows the + Resource Factory to give up ownership of objects it creates (as + it should). Removed the ACE_Dynamic_Service_Dependency instance + member, which was a crude attempt at solving the issue, + described in bug#2651. + Mon Sep 18 19:54:49 UTC 2006 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/be/be_visitor_union_branch/private_ch.cpp: diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 51eed8b6ea4..fb9de1c478d 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -362,6 +362,9 @@ TAO_ORB_Core::~TAO_ORB_Core (void) ::CORBA::release (this->orb_); + delete this->codeset_manager_; + this->codeset_manager_ = 0; + delete this->config_; this->config_ = 0; } diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index efd682a3ce8..d114ef39412 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -1261,7 +1261,7 @@ protected: /// Hold the flushing strategy TAO_Flushing_Strategy *flushing_strategy_; - /// Code Set Manager - points to service object in the service repo + /// Code Set Manager, received from the Resource Factory TAO_Codeset_Manager *codeset_manager_; /// ORB's service configuration diff --git a/TAO/tao/default_resource.cpp b/TAO/tao/default_resource.cpp index 67095ea740c..a76d8d81cd5 100644 --- a/TAO/tao/default_resource.cpp +++ b/TAO/tao/default_resource.cpp @@ -33,6 +33,71 @@ ACE_RCSID (tao, TAO_BEGIN_VERSIONED_NAMESPACE_DECL +TAO_Codeset_Parameters::TAO_Codeset_Parameters (void) + : translators_ () + , native_ (0) +{ +}; + +TAO_Codeset_Parameters::~TAO_Codeset_Parameters (void) +{ + for (TAO_Codeset_Parameters::iterator i = + this->translators (); + !i.done (); + i.advance ()) + { + ACE_TCHAR** element = 0; + if (i.next (element)) + ACE_OS::free (*element); + } + + ACE_OS::free (this->native_); +} + +const ACE_TCHAR* +TAO_Codeset_Parameters::native (void) +{ + return (this->native_); +} + +void +TAO_Codeset_Parameters::apply_to (TAO_Codeset_Descriptor_Base *csd) +{ + if (csd == 0) + return; + + if (this->native () != 0) + csd->ncs (this->native ()); + + ACE_TCHAR** element = 0; + for (TAO_Codeset_Parameters::iterator i = this->translators (); + !i.done (); + i.advance ()) + { + if (i.next (element)) + csd->add_translator (*element); + } +} + +void +TAO_Codeset_Parameters::native (const ACE_TCHAR* n) +{ + ACE_OS::free (this->native_); + this->native_ = ACE_OS::strdup (n); +} + +void +TAO_Codeset_Parameters::add_translator (const ACE_TCHAR*name) +{ + this->translators_.enqueue_tail (ACE_OS::strdup (name)); +} + +TAO_Codeset_Parameters::iterator +TAO_Codeset_Parameters::translators (void) +{ + return this->translators_.begin (); +} + TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) : use_locked_data_blocks_ (1) , parser_names_count_ (0) @@ -60,12 +125,10 @@ TAO_Default_Resource_Factory::TAO_Default_Resource_Factory (void) , object_key_table_lock_type_ (TAO_THREAD_LOCK) , corba_object_lock_type_ (TAO_THREAD_LOCK) , flushing_strategy_type_ (TAO_LEADER_FOLLOWER_FLUSHING) - , codeset_manager_ (0) - , char_codeset_descriptor_ (0) - , wchar_codeset_descriptor_ (0) + , char_codeset_parameters_ () + , wchar_codeset_parameters_ () , resource_usage_strategy_ (TAO_Resource_Factory::TAO_EAGER) , drop_replies_ (true) - , principal_(0) { #if TAO_USE_LAZY_RESOURCE_USAGE_STRATEGY == 1 this->resource_usage_strategy_ = @@ -93,13 +156,9 @@ TAO_Default_Resource_Factory::~TAO_Default_Resource_Factory (void) CORBA::string_free (this->parser_names_[i]); delete [] this->parser_names_; - - delete codeset_manager_; - codeset_manager_ = 0; - - delete principal_; } + int TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) { @@ -190,12 +249,7 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) { ++curarg; if (curarg < argc) - { - if (this->char_codeset_descriptor_ == 0) - this->init_codeset_descriptors(); - if (this->char_codeset_descriptor_) - this->char_codeset_descriptor_->ncs (argv[curarg]); - } + this->char_codeset_parameters_.native (argv[curarg]); } else if (ACE_OS::strcasecmp (argv[curarg], @@ -203,12 +257,7 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) { ++curarg; if (curarg < argc) - { - if (this->wchar_codeset_descriptor_ == 0) - this->init_codeset_descriptors(); - if (this->wchar_codeset_descriptor_) - this->wchar_codeset_descriptor_->ncs (argv[curarg]); - } + this->wchar_codeset_parameters_.native (argv[curarg]); } else if (ACE_OS::strcasecmp (argv[curarg], @@ -216,26 +265,16 @@ TAO_Default_Resource_Factory::init (int argc, ACE_TCHAR *argv[]) { ++curarg; if (curarg < argc) - { - if (this->char_codeset_descriptor_ == 0) - this->init_codeset_descriptors(); - if (this->char_codeset_descriptor_) - this->char_codeset_descriptor_->add_translator (argv[curarg]); - } + this->char_codeset_parameters_.add_translator (argv[curarg]); } - /// CodeSet Translators + /// CodeSet Translators else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("-ORBWCharCodesetTranslator")) == 0) { ++curarg; if (curarg < argc) - { - if (this->wchar_codeset_descriptor_ == 0) - this->init_codeset_descriptors(); - if (this->wchar_codeset_descriptor_) - this->wchar_codeset_descriptor_->add_translator (argv[curarg]); - } + this->wchar_codeset_parameters_.add_translator (argv[curarg]); } else if (ACE_OS::strcasecmp (argv[curarg], @@ -601,6 +640,7 @@ TAO_Default_Resource_Factory::add_to_ior_parser_names (const char *curarg) return 0; } + // This is virtual and protected... int TAO_Default_Resource_Factory::load_default_protocols (void) @@ -1180,28 +1220,42 @@ TAO_Default_Resource_Factory::disable_factory (void) TAO_Codeset_Manager * TAO_Default_Resource_Factory::codeset_manager(void) { - if (this->codeset_manager_) - return this->codeset_manager_; - TAO_Codeset_Manager_Factory_Base *factory = ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance ("TAO_Codeset"); - this->codeset_manager_ = factory->create (); - return this->codeset_manager_; -} + if (factory == 0) + { + if (TAO_debug_level >= 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory") + ACE_TEXT (" - unable to find codeset manager factory.\n"))); + return 0; + } -void -TAO_Default_Resource_Factory::init_codeset_descriptors(void) -{ - if (this->char_codeset_descriptor_) - return; - if (this->codeset_manager() == 0) - return; + TAO_Codeset_Manager* mgr = factory->create (); + + if (mgr == 0) + { + if (TAO_debug_level >= 2) + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory") + ACE_TEXT (" - unable to create codeset manager.\n"))); + return 0; + } + + + ACE_Auto_Ptr<TAO_Codeset_Manager> safemgr (mgr); + + if (TAO_debug_level >= 1) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("TAO (%P|%t) Default_Resource_Factory - codeset manager=%@\n"), + mgr)); + + this->char_codeset_parameters_.apply_to (mgr->char_codeset_descriptor()); + this->wchar_codeset_parameters_.apply_to (mgr->wchar_codeset_descriptor()); + + return safemgr.release (); - this->char_codeset_descriptor_ = - this->codeset_manager_->char_codeset_descriptor(); - this->wchar_codeset_descriptor_ = - this->codeset_manager_->wchar_codeset_descriptor(); } TAO_Resource_Factory::Resource_Usage diff --git a/TAO/tao/default_resource.h b/TAO/tao/default_resource.h index 8c04fa14372..e2f072bbf84 100644 --- a/TAO/tao/default_resource.h +++ b/TAO/tao/default_resource.h @@ -17,7 +17,6 @@ #include /**/ "ace/pre.h" #include "ace/Service_Config.h" -#include "ace/Dynamic_Service_Dependency.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -37,6 +36,48 @@ class TAO_LF_Strategy; class TAO_Codeset_Descriptor_Base; /** + * @class TAO_Codeset_Parametes + * + * @brief A simple storage class for the native codeset and any + * translators that must be configured when creating an instance of + * codeset manager. + * + * The Resource Factory uses two instances of this class during its + * initialization, to capture any native codeset or translators + * settings. The RF later uses these parameters when creating + * instances of the codeset manager. + * + * Perhaps, the best would be to place the responsibility for codeset + * manager's configuration with the the codeset manager factory? + * + */ +class TAO_Export TAO_Codeset_Parameters +{ +private: + ACE_Unbounded_Queue<ACE_TCHAR*> translators_; + ACE_TCHAR* native_; + +private: + TAO_Codeset_Parameters (const TAO_Codeset_Parameters&); + TAO_Codeset_Parameters& operator= (const TAO_Codeset_Parameters&); + + typedef ACE_Unbounded_Queue_Iterator<ACE_TCHAR*> iterator; + +public: + TAO_Codeset_Parameters (void); + ~TAO_Codeset_Parameters (void); + const ACE_TCHAR* native (void); + void native (const ACE_TCHAR* n); + void add_translator (const ACE_TCHAR*name); + iterator translators (void); + + /// Apply the parameters to the said descriptor + void apply_to (TAO_Codeset_Descriptor_Base *csd); +}; + + + +/** * @class TAO_Default_Resource_Factory * * @brief TAO's default resource factory @@ -234,7 +275,7 @@ protected: bool use_local_memory_pool_; private: - void init_codeset_descriptors (void); + // void init_codeset_descriptors (void); enum Lock_Type { @@ -261,9 +302,10 @@ private: /// Type of flushing strategy configured Flushing_Strategy_Type flushing_strategy_type_; - TAO_Codeset_Manager *codeset_manager_; - TAO_Codeset_Descriptor_Base *char_codeset_descriptor_; - TAO_Codeset_Descriptor_Base * wchar_codeset_descriptor_; + // Initialization options. To be used later when creating a codeset + // manager instance (s) + TAO_Codeset_Parameters char_codeset_parameters_; + TAO_Codeset_Parameters wchar_codeset_parameters_; /// Resource usage strategy Resource_Usage resource_usage_strategy_; @@ -271,14 +313,10 @@ private: /// Flag to indicate whether replies should be dropped during ORB /// shutdown. bool drop_replies_; - - // Makes a dependency on a specific dynamic service ("TAO_Codeset") explicit. - // It helps to keep the corresponding DLL around until the last instance - // is destroyed. Note that failure to delete the instances will "pin" the - // DLL in memory, preventing it from being unloaded on demand. - ACE_Dynamic_Service_Dependency *principal_; }; + + TAO_END_VERSIONED_NAMESPACE_DECL ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_Default_Resource_Factory) |