From b0132099959c23e3ca2c3160dcaf18184584d0c8 Mon Sep 17 00:00:00 2001 From: Johnny Willemsen Date: Thu, 6 Dec 2018 15:04:20 +0100 Subject: Remove default argument of 0 to remove_server, when we know the process id, we pass it, this way when the server itself invokes server_is_shutting_down we need to retrieve the current process id and use it * TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp: * TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp: * TAO/orbsvcs/ImplRepo_Service/LiveCheck.h: * TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp: * TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp: --- TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp | 7 +-- TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp | 53 +++++++++++++--------- TAO/orbsvcs/ImplRepo_Service/LiveCheck.h | 2 +- .../ImplRepo_Service/Locator_Repository.cpp | 2 +- .../ImplRepo_Service/Shared_Backing_Store.cpp | 4 +- 5 files changed, 40 insertions(+), 28 deletions(-) (limited to 'TAO/orbsvcs') diff --git a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp index ebc147df713..ea34a46ea25 100644 --- a/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/ImR_Locator_i.cpp @@ -182,8 +182,9 @@ ImR_Locator_i::init_with_orb (CORBA::ORB_ptr orb) { // We have read an existing configuration from the repository // and when a server is not alive we reset it, it could have - // been shutdown when we where offline - this->pinger_.remove_server (active->ping_id()); + // been shutdown when we where offline. We don't know its process + // id so pass zero + this->pinger_.remove_server (active->ping_id(), 0); info.edit()->reset_runtime (); active->reset_runtime (); continue; @@ -1387,7 +1388,7 @@ ImR_Locator_i::server_is_shutting_down if (!info->is_mode(ImplementationRepository::PER_CLIENT)) { - this->pinger_.remove_server (info->ping_id()); + this->pinger_.remove_server (info->ping_id(), info->pid); { AsyncAccessManager_ptr aam = this->find_aam (info->ping_id (), false); if (aam.is_nil()) diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp index bd15d396565..218451db95f 100644 --- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.cpp @@ -885,7 +885,7 @@ LiveCheck::remove_server (const char *server, int pid) if (ImR_Locator_i::debug () > 0) { ORBSVCS_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) LiveCheck::remove_server <%C> pid <%d> entry pid <%d>") + ACE_TEXT ("(%P|%t) LiveCheck::remove_server <%C> pid <%d> entry pid <%d> ") ACE_TEXT ("called during handle_timeout\n"), server, pid, entry->pid ())); } if (!this->in_handle_timeout ()) @@ -897,16 +897,13 @@ LiveCheck::remove_server (const char *server, int pid) } else { - // pid can be zero when the server does inform us that it is shutting down, because - // of that we need to store the entry pid for removal later, not that we remove - // the wrong entry later on if (ImR_Locator_i::debug () > 0) { ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) LiveCheck::remove_server <%C> pid <%d> entry pid <%d> ") ACE_TEXT ("called during handle_timeout\n"), server, pid, entry->pid ())); } - this->removed_entries_.insert_tail (std::make_pair (s, entry->pid ())); + this->removed_entries_.insert_tail (std::make_pair (s, pid)); } } else @@ -926,28 +923,42 @@ LiveCheck::remove_deferred_servers (void) { if (!this->removed_entries_.is_empty ()) { - NamePidStack::iterator re_end = this->removed_entries_.end(); - for (NamePidStack::iterator re = this->removed_entries_.begin(); - re != re_end; - ++re) + // When we are in handle_timeout we can't remove deferred servers + if (!this->in_handle_timeout ()) + { + NamePidStack::iterator re_end = this->removed_entries_.end(); + for (NamePidStack::iterator re = this->removed_entries_.begin(); + re != re_end; + ++re) + { + NamePidPair const & name_pid_pair = (*re); + if (ImR_Locator_i::debug () > 0) + { + ORBSVCS_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) LiveCheck::remove_deferred_servers ") + ACE_TEXT ("removing <%C> pid <%d>\n"), + name_pid_pair.first.c_str(), name_pid_pair.second)); + } + // Now try to remove the server, remove_server + // will make sure that we only remove the server when the + // name and pid match. These could potentially not + // match when the server has already been restarted between the + // moment it got in the removed_entries_ stack and this point + // where we remove it from the internal administration + this->remove_server (name_pid_pair.first.c_str(), name_pid_pair.second); + } + this->removed_entries_.reset (); + } + else { - NamePidPair const & name_pid_pair = (*re); if (ImR_Locator_i::debug () > 0) { ORBSVCS_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) LiveCheck::remove_deferred_entries ") - ACE_TEXT ("removing <%C> pid <%d>\n"), - name_pid_pair.first.c_str(), name_pid_pair.second)); + ACE_TEXT ("(%P|%t) LiveCheck::remove_deferred_servers ") + ACE_TEXT ("Can't remove <%d> servers because we are still in handle timeout\n"), + this->removed_entries_.size ())); } - // Now try to remove the server, remove_server - // will make sure that we only remove the server when the - // name and pid match. These could potentially not - // match when the server has already been restarted between the - // moment it got in the removed_entries_ stack and this point - // where we remove it from the internal administration - this->remove_server (name_pid_pair.first.c_str(), name_pid_pair.second); } - this->removed_entries_.reset (); } } diff --git a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h index 25c70fe5f45..00742ce90b7 100644 --- a/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h +++ b/TAO/orbsvcs/ImplRepo_Service/LiveCheck.h @@ -260,7 +260,7 @@ class Locator_Export LiveCheck : public ACE_Event_Handler bool may_ping, ImplementationRepository::ServerObject_ptr ref); void set_pid (const char *server, int pid); - void remove_server (const char *server, int pid = 0); + void remove_server (const char *server, int pid); bool remove_per_client_entry (LiveEntry *entry); bool add_listener (LiveListener *listener); bool add_poll_listener (LiveListener *listener); diff --git a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp index 2e799b0a317..10c2f2b3aff 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Locator_Repository.cpp @@ -331,7 +331,7 @@ Locator_Repository::unregister_if_address_reused (const ACE_CString& fqname, ACE_TEXT ("(%P|%t) ImR: reuse address <%C> so remove server <%C>\n"), info->partial_ior.c_str (), info->poa_name.c_str ())); } - imr_locator->pinger ().remove_server (info->key_name_.c_str()); + imr_locator->pinger ().remove_server (info->key_name_.c_str(), info->pid); AsyncAccessManager_ptr aam = imr_locator->find_aam (info->key_name_.c_str ()); if (!aam.is_nil()) { diff --git a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp index ff0e15f1898..98cf6ba0a15 100644 --- a/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp +++ b/TAO/orbsvcs/ImplRepo_Service/Shared_Backing_Store.cpp @@ -945,7 +945,7 @@ Shared_Backing_Store::load_server (Server_Info *info, this->create_server (server_started, si); if (was_started && !is_started) { - this->opts_.pinger ()->remove_server (si->key_name_.c_str ()); + this->opts_.pinger ()->remove_server (si->key_name_.c_str (), 0); } if (!was_started && is_started) { @@ -1089,7 +1089,7 @@ Shared_Backing_Store::process_updates (void) } else { - this->opts_.pinger ()->remove_server (name.c_str()); + this->opts_.pinger ()->remove_server (name.c_str(), 0); this->servers().unbind (name); } break; -- cgit v1.2.1