diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2015-11-24 19:30:37 +0100 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2015-11-24 19:30:37 +0100 |
commit | 5444deb74872256b158cc66f35836c81cb92c071 (patch) | |
tree | 76083aaa8d155fb55646a8c88e616ceee6f3fed3 | |
parent | 87b1f9e8dc33b6d5b33b21301ed24c54ccbc20ab (diff) | |
parent | 93978086bf5a23fe0ed0d447252159ffabe0e987 (diff) | |
download | ATCD-5444deb74872256b158cc66f35836c81cb92c071.tar.gz |
Merge branch 'master' of git://github.com/DOCGroup/ATCD
-rw-r--r-- | ACE/README | 2 | ||||
-rw-r--r-- | ACE/ace/Array_Map.h | 11 | ||||
-rw-r--r-- | ACE/ace/Array_Map.inl | 8 | ||||
-rw-r--r-- | ACE/ace/INET_Addr.cpp | 2 | ||||
-rw-r--r-- | TAO/NEWS | 4 | ||||
-rw-r--r-- | TAO/bin/imr_tests.lst | 2 | ||||
-rw-r--r-- | TAO/bin/tao_other_tests.lst | 2 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp | 25 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h | 4 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp | 389 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h | 21 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp | 35 | ||||
-rw-r--r-- | TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h | 2 | ||||
-rwxr-xr-x | TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl | 45 | ||||
-rw-r--r-- | TAO/tao/ImR_Client/ImplRepo.idl | 5 |
15 files changed, 406 insertions, 151 deletions
diff --git a/ACE/README b/ACE/README index ba3a21e1517..aece97d8c07 100644 --- a/ACE/README +++ b/ACE/README @@ -100,7 +100,7 @@ following class categories: . The ADAPTIVE Service Executive -- A user-level implementation of System V STREAMS, that supports modular integration of - hierarchically-related communicaion services; + hierarchically-related communication services; . Concurrency -- Various types of higher-level concurrency diff --git a/ACE/ace/Array_Map.h b/ACE/ace/Array_Map.h index adad5218748..d9dae1190eb 100644 --- a/ACE/ace/Array_Map.h +++ b/ACE/ace/Array_Map.h @@ -33,6 +33,14 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL +#if defined __SUNPRO_CC && !defined _RWSTD_ALLOCATOR +# define ACE_ARRAY_MAP_DEFAULT_ALLOCATOR(K, V) std::allocator_interface< \ + std::allocator<void>, \ + std::pair<K, V> > +#else +# define ACE_ARRAY_MAP_DEFAULT_ALLOCATOR(K, V) std::allocator<std::pair<K, V> > +#endif + /** * @class ACE_Array_Map * @@ -83,7 +91,8 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL * -# Copy constructor * -# operator= */ -template<typename Key, typename Value, class EqualTo = std::equal_to<Key>, class Alloc = std::allocator<std::pair<Key, Value> > > +template<typename Key, typename Value, class EqualTo = std::equal_to<Key>, + class Alloc = ACE_ARRAY_MAP_DEFAULT_ALLOCATOR (Key, Value) > class ACE_Array_Map { public: diff --git a/ACE/ace/Array_Map.inl b/ACE/ace/Array_Map.inl index 0225dc8d5dc..32e7848c02d 100644 --- a/ACE/ace/Array_Map.inl +++ b/ACE/ace/Array_Map.inl @@ -1,19 +1,13 @@ // -*- C++ -*- ACE_BEGIN_VERSIONED_NAMESPACE_DECL -#if defined __SUNPRO_CC && !defined _RWSTD_ALLOCATOR -# define ACE_SUNCC_CAST (pointer) -#else -# define ACE_SUNCC_CAST -#endif - template<typename Key, typename Value, class EqualTo, class Alloc> ACE_INLINE ACE_Array_Map<Key, Value, EqualTo, Alloc>::ACE_Array_Map ( typename ACE_Array_Map<Key, Value, EqualTo, Alloc>::size_type s) : size_ (0) , capacity_ (s) - , nodes_ (s == 0 ? 0 : ACE_SUNCC_CAST this->alloc_.allocate (s)) + , nodes_ (s == 0 ? 0 : this->alloc_.allocate (s)) { std::uninitialized_fill_n (this->nodes_, s, value_type ()); } diff --git a/ACE/ace/INET_Addr.cpp b/ACE/ace/INET_Addr.cpp index 83f4e73bd59..20d815808e2 100644 --- a/ACE/ace/INET_Addr.cpp +++ b/ACE/ace/INET_Addr.cpp @@ -846,7 +846,7 @@ ACE_INET_Addr::get_host_name_i (char hostname[], size_t len) const #endif sizeof (sockaddr_in); - const int res = ACE_OS::getnameinfo ((const sockaddr *) &this->inet_addr_, + const int res = ACE_OS::getnameinfo ((const sockaddr *) this->get_addr (), addr_size, hostname, static_cast<ACE_SOCKET_LEN> (len), 0, 0, 0); @@ -1,6 +1,10 @@ USER VISIBLE CHANGES BETWEEN TAO-2.3.3 and TAO-2.3.4 ==================================================== +. Added a "force remove" option to the Implementation repository that will remove + a server entry from the ImR Locator repository and kill any running instance with + a single command. + USER VISIBLE CHANGES BETWEEN TAO-2.3.2 and TAO-2.3.3 ==================================================== diff --git a/TAO/bin/imr_tests.lst b/TAO/bin/imr_tests.lst index 9bffac47a1e..db263502cf2 100644 --- a/TAO/bin/imr_tests.lst +++ b/TAO/bin/imr_tests.lst @@ -29,6 +29,8 @@ TAO/orbsvcs/tests/ImplRepo/double_start/run_test.pl -kill: !ST !MINIMUM !CORBA_E TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -start_delay 3: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO +TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -force: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO +TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -force -signal 15: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_slow_server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/oneway/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/locked/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO !OSX diff --git a/TAO/bin/tao_other_tests.lst b/TAO/bin/tao_other_tests.lst index bd8aed52012..398ec11f066 100644 --- a/TAO/bin/tao_other_tests.lst +++ b/TAO/bin/tao_other_tests.lst @@ -134,6 +134,8 @@ TAO/orbsvcs/tests/ImplRepo/double_start/run_test.pl -kill: !ST !MINIMUM !CORBA_E TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -start_delay 3: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO +TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -force: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO +TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl -rm2523 -force -signal 15: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/kill_slow_server/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/oneway/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO TAO/orbsvcs/tests/ImplRepo/locked/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !WCHAR !LynxOS !ACE_FOR_TAO diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp index 14e32f9b82b..969c6b41080 100644 --- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.cpp @@ -15,6 +15,7 @@ AsyncAccessManager::AsyncAccessManager (UpdateableServerInfo &info, :info_(info), manual_start_ (false), retries_ (info->start_limit_), + remove_on_death_rh_ (0), locator_ (locator), poa_ (locator.root_poa ()), rh_list_ (), @@ -49,7 +50,8 @@ AsyncAccessManager::started_running (void) bool AsyncAccessManager::is_terminating (void) { - return this->status_ == ImplementationRepository::AAM_ACTIVE_TERMINATE; + return this->status_ == ImplementationRepository::AAM_ACTIVE_TERMINATE || + remove_on_death_rh_ != 0; } bool @@ -138,6 +140,22 @@ AsyncAccessManager::add_interest (ImR_ResponseHandler *rh, bool manual) } } +bool +AsyncAccessManager::force_remove_rh (ImR_ResponseHandler *rh) +{ + bool busy = true; + if (this->remove_on_death_rh_ == 0 || rh == 0) + { + if (rh == 0) + { + delete this->remove_on_death_rh_; + } + this->remove_on_death_rh_ = rh; + busy = false; + } + return busy; +} + void AsyncAccessManager::remote_state (ImplementationRepository::AAM_Status state) { @@ -181,6 +199,11 @@ AsyncAccessManager::final_state (bool active) ACE_TEXT ("removing this from map, server = %s\n"), this, info_->ping_id ())); } + if (this->remove_on_death_rh_ != 0) + { + this->locator_.remove_server_i (this->info_.edit()); + this->remove_on_death_rh_->send_ior(""); + } AsyncAccessManager_ptr aam (this); this->locator_.remove_aam (aam); aam._retn(); // release w/o decrementing since table held last reference. diff --git a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h index 3c770ae5d39..299cf0f10c6 100644 --- a/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h +++ b/TAO/orbsvcs/ImplRepo_Service/AsyncAccessManager.h @@ -64,13 +64,14 @@ class Locator_Export AsyncAccessManager void add_interest (ImR_ResponseHandler *rh, bool manual); ImplementationRepository::AAM_Status status (void) const; + bool force_remove_rh (ImR_ResponseHandler *rh); void activator_replied (bool success, int pid); void server_is_running (const char *partial_ior, ImplementationRepository::ServerObject_ptr ref); void server_is_shutting_down (void); void shutdown_initiated (void); - bool notify_child_death (int pid = 0); + bool notify_child_death (int pid); void ping_replied (LiveStatus server); AsyncAccessManager *_add_ref (void); @@ -88,6 +89,7 @@ class Locator_Export AsyncAccessManager UpdateableServerInfo info_; bool manual_start_; int retries_; + ImR_ResponseHandler *remove_on_death_rh_; ImR_Locator_i &locator_; PortableServer::POA_var poa_; ACE_Vector<ImR_ResponseHandler *> rh_list_; diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp index 87d5dcbe79d..01365a06b18 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp @@ -854,83 +854,91 @@ ImR_Locator_i::link_servers return; } -void -ImR_Locator_i::kill_server -(ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh, - const char * name, - CORBA::Short signum) +bool +ImR_Locator_i::kill_server_i (const Server_Info_Ptr &si, + CORBA::Short signum, + CORBA::Exception *& ex) { - Server_Info_Ptr si; - if (!this->get_info_for_name (name, si)) + if (si->is_mode(ImplementationRepository::PER_CLIENT)) { - CORBA::Exception *ex = - new ImplementationRepository::NotFound; - ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); - _tao_rh->kill_server_excep (&h); - return; - } - - if (!si->alt_info_.null ()) - { - si = si->alt_info_; - } - - UpdateableServerInfo info (this->repository_, si, true); - if (info->is_mode(ImplementationRepository::PER_CLIENT)) - { - CORBA::Exception *ex = - new ImplementationRepository::CannotComplete ("per-client server"); - ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); - _tao_rh->kill_server_excep (&h); - return; + ex = new ImplementationRepository::CannotComplete ("per-client server"); + return false; } Activator_Info_Ptr ainfo = this->get_activator (si->activator); if (ainfo.null ()) { - CORBA::Exception *ex = - new ImplementationRepository::CannotComplete ("no activator"); - ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); - _tao_rh->kill_server_excep (&h); - return; - } + ex = new ImplementationRepository::CannotComplete ("no activator"); + return false; + } + ImplementationRepository::ActivatorExt_var actext = ImplementationRepository::ActivatorExt::_narrow (ainfo->activator.in()); + if (CORBA::is_nil (actext.in())) { - CORBA::Exception *ex = - new ImplementationRepository::CannotComplete ("activator incompatible"); - ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); - _tao_rh->kill_server_excep (&h); - return; + ex = new ImplementationRepository::CannotComplete ("activator incompatible"); + return false; } - if (!actext->kill_server (si->key_name_.c_str(), si->pid, signum)) + return actext->kill_server (si->key_name_.c_str(), si->pid, signum); +} + +void +ImR_Locator_i::kill_server +(ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh, + const char * name, CORBA::Short signum) +{ + CORBA::Exception *ex = 0; + Server_Info_Ptr si; + if (!this->get_info_for_name (name, si)) { - CORBA::Exception *ex = - new ImplementationRepository::CannotComplete ("server not running"); - ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); - _tao_rh->kill_server_excep (&h); + ex = new ImplementationRepository::NotFound; } else { - _tao_rh->kill_server (); - AsyncAccessManager_ptr aam = this->find_aam (si->key_name_.c_str ()); - if (!aam.is_nil ()) + if (!si->alt_info_.null ()) { - aam->shutdown_initiated (); + si = si->alt_info_; + } + if (!this->kill_server_i (si, signum, ex)) + { + if (ex == 0) + { + ex = new ImplementationRepository::CannotComplete ("server not running"); + } } } + if (ex != 0) + { + ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); + _tao_rh->kill_server_excep (&h); + return; + } + + _tao_rh->kill_server (); + AsyncAccessManager_ptr aam = this->find_aam (si->key_name_.c_str ()); + if (!aam.is_nil ()) + { + aam->shutdown_initiated (); + } } void -ImR_Locator_i::destroy_poa (const ACE_CString &poa_name) +ImR_Locator_i::remove_server_i (const Server_Info_Ptr &info) { - PortableServer::POA_var poa = findPOA (poa_name.c_str()); - if (! CORBA::is_nil (poa.in ())) + if (debug_ > 1) + ORBSVCS_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) ImR: Removing Server <%C>...\n"), + info->key_name_.c_str())); + + ACE_CString poa_name = info->poa_name; + if (this->repository_->remove_server (info->key_name_, this) == 0) { - bool etherealize = true; - bool wait = false; - poa->destroy (etherealize, wait); + this->destroy_poa (poa_name); + if (debug_ > 0) + ORBSVCS_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) ImR: Removed Server <%C>.\n"), + info->key_name_.c_str())); } } @@ -971,20 +979,7 @@ ImR_Locator_i::remove_server _tao_rh->remove_server_excep (&h); return; } - if (debug_ > 1) - ORBSVCS_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) ImR: Removing Server <%C>...\n"), - info->key_name_.c_str())); - - ACE_CString poa_name = info->poa_name; - if (this->repository_->remove_server (info->key_name_, this) == 0) - { - this->destroy_poa (poa_name); - if (debug_ > 0) - ORBSVCS_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) ImR: Removed Server <%C>.\n"), - id)); - } + this->remove_server_i (info); } else { @@ -998,6 +993,95 @@ ImR_Locator_i::remove_server _tao_rh->remove_server (); } +void +ImR_Locator_i::force_remove_server +(ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh, + const char *name, CORBA::Short signum) +{ + CORBA::Exception *ex = 0; + Server_Info_Ptr si; + AsyncAccessManager_ptr aam; + if (this->opts_->readonly ()) + { + ORBSVCS_ERROR ((LM_ERROR, + ACE_TEXT ("(%P|%t) ImR: Can't remove server <%C> due to locked database.\n"), + name)); + ex = + new CORBA::NO_PERMISSION (CORBA::SystemException::_tao_minor_code + (TAO_IMPLREPO_MINOR_CODE, 0), + CORBA::COMPLETED_NO); + ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); + _tao_rh->force_remove_server_excep (&h); + return; + } + + + if (!this->get_info_for_name (name, si)) + { + ex = new ImplementationRepository::NotFound; + ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); + _tao_rh->force_remove_server_excep (&h); + return; + } + + if (!si->alt_info_.null ()) + { + si = si->alt_info_; + } + aam = this->find_aam (si->key_name_.c_str ()); + if (aam.is_nil ()) + { + this->remove_server_i (si); + _tao_rh->force_remove_server (); + return; + } + + ImR_ResponseHandler *aam_rh = + new ImR_Loc_ResponseHandler (ImR_Loc_ResponseHandler::LOC_FORCE_REMOVE_SERVER, + _tao_rh); + if (aam->force_remove_rh (aam_rh)) + { + delete aam_rh; + _tao_rh->force_remove_server (); + return; + } + + bool active = (signum > 0) ? + this->kill_server_i (si, signum, ex) : + this->shutdown_server_i (si, ex, true); + + if (ex != 0) + { + ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); + _tao_rh->force_remove_server_excep (&h); + aam->force_remove_rh (0); + return; + } + if (active) + { + aam->shutdown_initiated (); + } + else + { + aam->force_remove_rh (0); + remove_server_i (si); + _tao_rh->force_remove_server (); + } +} + +void +ImR_Locator_i::destroy_poa (const ACE_CString &poa_name) +{ + PortableServer::POA_var poa = findPOA (poa_name.c_str()); + if (! CORBA::is_nil (poa.in ())) + { + bool etherealize = true; + bool wait = false; + poa->destroy (etherealize, wait); + } +} + + PortableServer::POA_ptr ImR_Locator_i::findPOA (const char* name) { @@ -1012,27 +1096,27 @@ ImR_Locator_i::findPOA (const char* name) return PortableServer::POA::_nil (); } -void -ImR_Locator_i::shutdown_server -(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh, - const char* id) +bool +ImR_Locator_i::shutdown_server_i (const Server_Info_Ptr &si, + CORBA::Exception *&ex_ret, + bool force) { const CORBA::ULong TAO_MINOR_MASK = 0x00000f80; + const char *id = si->key_name_.c_str(); if (debug_ > 0) ORBSVCS_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) ImR: Shutting down server <%C>.\n"), - id)); + ACE_TEXT ("(%P|%t) ImR: Shutting down server <%C>.\n"), + id)); - UpdateableServerInfo info (this->repository_, id); + UpdateableServerInfo info (this->repository_, si); if (info.null ()) { ORBSVCS_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) ImR: shutdown_server () Cannot find info for server <%C>\n"), - id)); - CORBA::Exception *ex = new ImplementationRepository::NotFound; - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex); - _tao_rh->shutdown_server_excep (&h); - return; + ACE_TEXT ("(%P|%t) ImR: shutdown_server () ") + ACE_TEXT ("Cannot find info for server <%C>\n"), + id)); + ex_ret = new ImplementationRepository::NotFound; + return false; } this->connect_server (info); @@ -1040,19 +1124,11 @@ ImR_Locator_i::shutdown_server if (CORBA::is_nil (info->active_info()->server.in ())) { ORBSVCS_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) ImR: shutdown_server () Cannot connect to server <%C>\n"), - id)); - CORBA::Exception *ex = new ImplementationRepository::NotFound; - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex); - try - { - _tao_rh->shutdown_server_excep (&h); - } - catch (const CORBA::Exception &ex) - { - ex._tao_print_exception (ACE_TEXT ("reporting connect error\n")); - } - return; + ACE_TEXT ("(%P|%t) ImR: shutdown_server ()") + ACE_TEXT (" Cannot connect to server <%C>\n"), + id)); + ex_ret = new ImplementationRepository::NotFound; + return false; } try @@ -1062,15 +1138,7 @@ ImR_Locator_i::shutdown_server ImplementationRepository::ServerObject_var server = ImplementationRepository::ServerObject::_unchecked_narrow (obj.in ()); server->shutdown (); - // reset the server info on a successful call. A failure indicates the server isn't - // acting on the shutdown. Either it is shutting down already, or hasn't yet started, - // in which case the shutdown will need to be reissued. - info.edit ()->reset_runtime (); - AsyncAccessManager_ptr aam = this->find_aam (info->ping_id ()); - if (!aam.is_nil()) - { - aam->shutdown_initiated (); - } + return true; } catch (const CORBA::TIMEOUT &ex) { @@ -1083,9 +1151,10 @@ ImR_Locator_i::shutdown_server ACE_TEXT ("(%P|%t) ImR: Timeout while waiting for <%C> shutdown.\n"), id)); } - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate()); - _tao_rh->shutdown_server_excep (&h); - return; + if (!force && this->opts_->throw_shutdown_exceptions ()) + { + ex_ret = ex._tao_duplicate(); + } } catch (const CORBA::COMM_FAILURE& ex) { @@ -1096,11 +1165,9 @@ ImR_Locator_i::shutdown_server ACE_TEXT ("ImR: COMM_FAILURE while waiting for <%C> shutdown.\n"), id)); } - if (this->opts_->throw_shutdown_exceptions ()) + if (!force && this->opts_->throw_shutdown_exceptions ()) { - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate()); - _tao_rh->shutdown_server_excep (&h); - return; + ex_ret = ex._tao_duplicate(); } } catch (const CORBA::TRANSIENT& ex) @@ -1116,11 +1183,9 @@ ImR_Locator_i::shutdown_server ACE_TEXT ("ImR: TRANSIENT while waiting for <%C> shutdown.\n"), id)); } - if (this->opts_->throw_shutdown_exceptions ()) + if (!force && this->opts_->throw_shutdown_exceptions ()) { - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate()); - _tao_rh->shutdown_server_excep (&h); - return; + ex_ret = ex._tao_duplicate(); } } catch (const CORBA::Exception &ex) @@ -1131,15 +1196,47 @@ ImR_Locator_i::shutdown_server ACE_TEXT ("(%P|%t) ImR: Exception while shutting down <%C>\n"), id)); } - if (this->opts_->throw_shutdown_exceptions ()) + if (!force && this->opts_->throw_shutdown_exceptions ()) { - ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate()); - _tao_rh->shutdown_server_excep (&h); - return; + ex_ret = ex._tao_duplicate(); } } + return false; +} - _tao_rh->shutdown_server (); +void +ImR_Locator_i::shutdown_server +(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh, + const char* name) +{ + CORBA::Exception *ex = 0; + Server_Info_Ptr si; + + if (!this->get_info_for_name (name, si)) + { + ex = new ImplementationRepository::NotFound; + ImplementationRepository::AMH_AdministrationExceptionHolder h (ex); + _tao_rh->shutdown_server_excep (&h); + return; + } + + if (this->shutdown_server_i (si, ex, false)) + { + AsyncAccessManager_ptr aam = this->find_aam (si->ping_id ()); + if (!aam.is_nil()) + { + aam->shutdown_initiated (); + } + } + if (ex != 0) + { + ImplementationRepository::AMH_AdministrationExceptionHolder h (ex); + _tao_rh->shutdown_server_excep (&h); + } + else + { + _tao_rh->shutdown_server (); + } } void @@ -1688,13 +1785,22 @@ ImR_SyncResponseHandler::wait_for_result (void) //--------------------------------------------------------------------------- -ImR_Loc_ResponseHandler::ImR_Loc_ResponseHandler (Loc_Operation_Id opid, - ImplementationRepository::AMH_AdministrationResponseHandler_ptr rh) +ImR_Loc_ResponseHandler::ImR_Loc_ResponseHandler +(Loc_Operation_Id opid, + ImplementationRepository::AMH_AdministrationResponseHandler_ptr rh) :op_id_ (opid), resp_ (ImplementationRepository::AMH_AdministrationResponseHandler::_duplicate (rh)) { } +ImR_Loc_ResponseHandler::ImR_Loc_ResponseHandler +(Loc_Operation_Id opid, + ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr rh) + :op_id_ (opid), + ext_ (ImplementationRepository::AMH_AdministrationExtResponseHandler::_duplicate (rh)) +{ +} + ImR_Loc_ResponseHandler::~ImR_Loc_ResponseHandler (void) { } @@ -1702,6 +1808,11 @@ ImR_Loc_ResponseHandler::~ImR_Loc_ResponseHandler (void) void ImR_Loc_ResponseHandler::send_ior (const char *) { + if (CORBA::is_nil (this->resp_)) + { + this->send_ior_ext (""); + return; + } switch (this->op_id_) { case LOC_ACTIVATE_SERVER: @@ -1722,6 +1833,23 @@ ImR_Loc_ResponseHandler::send_ior (const char *) case LOC_SERVER_IS_SHUTTING_DOWN: resp_->server_is_shutting_down (); break; + default: + break; + }; + + delete this; +} + +void +ImR_Loc_ResponseHandler::send_ior_ext (const char *) +{ + switch (this->op_id_) + { + case LOC_FORCE_REMOVE_SERVER: + ext_->force_remove_server (); + break; + default: + break; }; delete this; @@ -1730,6 +1858,11 @@ ImR_Loc_ResponseHandler::send_ior (const char *) void ImR_Loc_ResponseHandler::send_exception (CORBA::Exception *ex) { + if (CORBA::is_nil (this->resp_)) + { + this->send_exception_ext (ex); + return; + } ImplementationRepository::AMH_AdministrationExceptionHolder h (ex); switch (this->op_id_) { @@ -1751,6 +1884,22 @@ ImR_Loc_ResponseHandler::send_exception (CORBA::Exception *ex) case LOC_SERVER_IS_SHUTTING_DOWN: resp_->server_is_shutting_down_excep (&h); break; + default: + break; + }; + delete this; +} +void +ImR_Loc_ResponseHandler::send_exception_ext (CORBA::Exception *ex) +{ + ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex); + switch (this->op_id_) + { + case LOC_FORCE_REMOVE_SERVER: + ext_->force_remove_server_excep (&h); + break; + default: + break; }; delete this; } diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h index 3aafa37cad5..2a977305994 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.h @@ -117,6 +117,11 @@ public: (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh, const char * name); + virtual void force_remove_server + (ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh, + const char * name, + CORBA::Short signum); + virtual void find (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh, const char * name); @@ -163,6 +168,7 @@ public: PortableServer::POA_ptr root_poa (void); Activator_Info_Ptr get_activator (const ACE_CString& name); + void remove_server_i (const Server_Info_Ptr &si); void destroy_poa (const ACE_CString &poa_name); void remove_aam (AsyncAccessManager_ptr &aam); void remove_aam (const char *name); @@ -201,6 +207,14 @@ private: void remove_aam_i (const char *name, bool active); + bool kill_server_i (const Server_Info_Ptr &si, + CORBA::Short signum, + CORBA::Exception *&ex); + + bool shutdown_server_i (const Server_Info_Ptr &si, + CORBA::Exception *&ex, + bool force); + private: static int debug_; @@ -301,6 +315,7 @@ public: { LOC_ACTIVATE_SERVER, LOC_ADD_OR_UPDATE_SERVER, + LOC_FORCE_REMOVE_SERVER, LOC_REMOVE_SERVER, LOC_SHUTDOWN_SERVER, LOC_SERVER_IS_RUNNING, @@ -309,14 +324,20 @@ public: ImR_Loc_ResponseHandler (Loc_Operation_Id opid, ImplementationRepository::AMH_AdministrationResponseHandler_ptr rh); + ImR_Loc_ResponseHandler (Loc_Operation_Id opid, + ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr rh); virtual ~ImR_Loc_ResponseHandler (void); virtual void send_ior (const char *pior); virtual void send_exception (CORBA::Exception *ex); private: + void send_ior_ext (const char *pior); + void send_exception_ext (CORBA::Exception *ex); + Loc_Operation_Id op_id_; ImplementationRepository::AMH_AdministrationResponseHandler_var resp_; + ImplementationRepository::AMH_AdministrationExtResponseHandler_var ext_; }; diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp index fa1a27d2174..c5eaa18069f 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.cpp @@ -612,8 +612,10 @@ TAO_IMR_Op_Remove::print_usage (void) { ORBSVCS_ERROR ((LM_ERROR, "Removes a server entry\n" "\n" - "Usage: tao_imr [options] remove <name>\n" + "Usage: tao_imr [options] remove <name> [-f [-s <signum>]]\n" " where [options] are ORB options\n" + " -f forces shutdown or kill of a running server" + " -s specifies a signal for killing the server, if it is 0, a shutdown will be used" " where <name> is the POA name used by the server object\n" " -h Displays this\n")); } @@ -627,9 +629,11 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv) this->print_usage (); return -1; } + this->force_ = false; + this->signum_ = 0; // Skip both the program name and the "remove" command - ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("h")); + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("hfs:")); this->server_name_ = ACE_TEXT_ALWAYS_CHAR(argv[1]); int c; @@ -641,12 +645,19 @@ TAO_IMR_Op_Remove::parse (int argc, ACE_TCHAR **argv) case 'h': this->print_usage (); return -1; + case 'f': + this->force_ = true; + break; + case 's': + this->signum_ = ACE_OS::strtol (get_opts.opt_arg (), 0, 10); + break; default: ORBSVCS_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c)); this->print_usage (); return -1; } } + return 0; } @@ -1217,8 +1228,18 @@ TAO_IMR_Op_Remove::run (void) try { - this->imr_->remove_server (this->server_name_.c_str ()); - + if (this->force_) + { + ImplementationRepository::AdministrationExt_var ext = + ImplementationRepository::AdministrationExt::_narrow (imr_); + ACE_ASSERT (! CORBA::is_nil(ext)); + ext->force_remove_server (this->server_name_.c_str (), + this->signum_); + } + else + { + this->imr_->remove_server (this->server_name_.c_str ()); + } ORBSVCS_DEBUG ((LM_DEBUG, "Successfully removed server <%C>\n", this->server_name_.c_str ())); } @@ -1228,6 +1249,12 @@ TAO_IMR_Op_Remove::run (void) this->server_name_.c_str ())); return TAO_IMR_Op::NOT_FOUND; } + catch (const ImplementationRepository::CannotComplete& cc) + { + ORBSVCS_ERROR ((LM_ERROR, "Could not complete forced removal of server <%C>. reason: %C\n", + this->server_name_.c_str (), cc.reason.in() )); + return TAO_IMR_Op::CANNOT_COMPLETE; + } catch (const CORBA::NO_PERMISSION& np) { if ((np.minor () & 0x7FU) == 0xFU) //TAO_EBUSY_MINOR_CODE) diff --git a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h index 47d6238a70b..acdcc910380 100644 --- a/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h +++ b/TAO/orbsvcs/ImplRepo_Service/tao_imr_i.h @@ -287,6 +287,8 @@ protected: void print_usage (void); ACE_CString server_name_; + bool force_; + int signum_; }; diff --git a/TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl b/TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl index 3ae5136e69e..e162720d876 100755 --- a/TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl +++ b/TAO/orbsvcs/tests/ImplRepo/kill_server/run_test.pl @@ -18,8 +18,11 @@ my $signalnum = 9; my $rm2523 = 0; my $act_delay = 800; #msec my $start_delay = 0; #sec +my $rm_opts = ""; +my $force = 0; if ($#ARGV >= 0) { + my $sn_set = 0; for (my $i = 0; $i <= $#ARGV; $i++) { if ($ARGV[$i] eq '-debug') { $orb_debug = 4; @@ -36,15 +39,19 @@ if ($#ARGV >= 0) { elsif ($ARGV[$i] eq "-signal") { $i++; $signalnum = $ARGV[$i]; + $sn_set = 1; } elsif ($ARGV[$i] eq "-rm2523") { $rm2523 = 1; $signalnum = 15; $servers_count = 3; } + elsif ($ARGV[$i] eq "-force") { + $rm_opts = "-f"; + $force = 1; + } elsif ($ARGV[$i] eq "-start_delay") { $i++; - # $act_delay = 0; $start_delay = $ARGV[$i]; } else { @@ -52,6 +59,7 @@ if ($#ARGV >= 0) { exit 1; } } + $rm_opts .= " -s $signalnum" if ($force == 1 && $sn_set == 1); } #$ENV{ACE_TEST_VERBOSE} = "1"; @@ -253,7 +261,7 @@ sub update_normal() $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". "add $objprefix" . '_' . $i . "_a -c \"". $srv_server_cmd[$i]. - " -ORBUseIMR 1 -n $i -ORBDebugLevel 10 -ORBLogFile svr.log ". + " -ORBUseIMR 1 -n $i ". "-orbendpoint iiop://localhost: " . "-ORBInitRef ImplRepoService=file://$srv_imriorfile\""); @@ -290,10 +298,10 @@ sub remove_entry(@) my $obj = shift; my $i = 1; $TI->Arguments ("-ORBInitRef ImplRepoService=file://$ti_imriorfile ". - "remove $objprefix" . '_' . $i . "_$obj"); + "remove $objprefix" . '_' . $i . "_$obj $rm_opts"); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0) { - print STDERR "tao_imr remove returned $TI_status\n"; + print STDERR "tao_imr remove $rm_opts returned $TI_status\n"; } } @@ -351,7 +359,7 @@ sub shutdown_servers(@) "kill $objprefix" . '_' . $i . "_a -s $signum" ); $TI_status = $TI->SpawnWaitKill ($ti->ProcessStartWaitInterval()); if ($TI_status != 0 && $TI_status != 5) { - print STDERR "ERROR: tao_imr shutdown returned $TI_status\n"; + print STDERR "ERROR: tao_imr kill returned $TI_status\n"; $status = 1; last; } @@ -411,15 +419,20 @@ sub rm2523_test make_server_requests(); list_servers("-a"); - print "Update to manual\n"; - update_manual(); - list_servers("-v"); + if ($force == 0) { + print "Update to manual\n"; + update_manual(); + list_servers("-v"); - print "kill the one\n"; - kill_the_one(); - list_servers(""); + print "kill the one\n"; + kill_the_one(); + list_servers(""); - print "remove primary\n"; + print "remove primary\n"; + } + else { + print "force remove primary\n"; + } remove_entry("a"); list_servers(""); @@ -446,9 +459,11 @@ sub rm2523_test sleep 2; print "triggering the one\n"; trigger_the_one (); - kill_the_one (); - list_servers("-a"); - sleep 1; + if ($force == 0) { + kill_the_one (); + list_servers("-a"); + sleep 1; + } remove_entry ("a"); wait_for_client (); diff --git a/TAO/tao/ImR_Client/ImplRepo.idl b/TAO/tao/ImR_Client/ImplRepo.idl index a6e7c5663c1..f5c9075f5f2 100644 --- a/TAO/tao/ImR_Client/ImplRepo.idl +++ b/TAO/tao/ImR_Client/ImplRepo.idl @@ -206,6 +206,11 @@ module ImplementationRepository /// Have the approprate activator send a signal to the named server process void kill_server (in string server, in short signum) raises(NotFound, CannotComplete); + + /// Combine the action of shutting down a running server instance if any via + /// a shutdown command if signum is 0, or via kill if signum is nonzero + void force_remove_server (in string server, in short signum) + raises(NotFound, CannotComplete); }; }; |