void
AsyncAccessManager::final_state (bool active)
{
  bool success = this->status_ == ImplementationRepository::AAM_SERVER_READY;
  this->info_.edit (active)->started (success);
  this->retries_ = this->info_->start_limit_;
  if (active)
    {
      this->info_.update_repo ();
    }
  this->notify_waiters ();
  this->manual_start_ = false;

  if (active)
    {
      this->info_.notify_remote_access (this->status_);
    }
  if (this->info_->is_mode (ImplementationRepository::PER_CLIENT) ||
      this->status_ != ImplementationRepository::AAM_SERVER_READY)
    {
      if (ImR_Locator_i::debug () > 5)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) AsyncAccessManager(%@)::final_state ")
                          ACE_TEXT ("removing this from map, server = %s\n"),
                          this, info_->ping_id ()));
        }
      AsyncAccessManager_ptr aam (this);
      this->locator_.remove_aam (aam);
      aam._retn(); // release w/o decrementing since table held last reference.
    }
}
void
ImR_Locator_i::child_death_i (const char* name, int pid)
{
  if (debug_ > 1)
    ORBSVCS_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%P|%t) ImR: Server[%d] has died <%C>.\n"),
                    pid, name));

  this->pinger_.remove_server (name, pid);
  AsyncAccessManager_ptr aam (this->find_aam (name, false));
  bool terminated = !aam.is_nil () && aam->notify_child_death (pid);
  aam = this->find_aam (name, true);
  if (!terminated && !aam.is_nil ())
    {
      terminated = aam->notify_child_death (pid);
    }
  UpdateableServerInfo info(this->repository_, name, pid);
  if (! info.null ())
    {
      info.edit ()->reset_runtime ();
    }
  else
    {
      if (debug_ > 1)
        ORBSVCS_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%P|%t) ImR: Failed to find server/pid in repository.\n")));
    }

}
AsyncAccessManager *
ImR_Locator_i::create_aam (UpdateableServerInfo &info, bool running)
{
  AsyncAccessManager_ptr aam;
  ACE_NEW_RETURN (aam, AsyncAccessManager (info, *this), 0);
  if (running)
    {
      aam->started_running ();
    }
  {
    this->aam_active_.insert_tail (aam);
  }
  return aam._retn ();
}
void
ImR_Locator_i::activate_server_i (UpdateableServerInfo& info,
                                  bool manual_start,
                                  ImR_ResponseHandler *rh)
{
  AsyncAccessManager_ptr aam;
  if (info->is_mode(ImplementationRepository::PER_CLIENT))
    {
      ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
      aam = this->create_aam (info);
    }
  else
    {
      aam = this->find_aam (info->ping_id ());
      if (aam.is_nil())
        {
          ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_);
          aam = this->create_aam (info);
        }
    }
  aam->add_interest (rh, manual_start);
}
void
ImR_Locator_i::server_is_shutting_down
  (ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
   const char* fqname)
{
  UpdateableServerInfo info (this->repository_, fqname);
  if (info.null ())
    {
      if (debug_ > 1)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) ImR_Locator_i::server_is_shutting_down: ")
                      ACE_TEXT ("Unknown server: %C\n"),
                      fqname));
        }
      _tao_rh->server_is_shutting_down ();
      return;
    }

  if (debug_ > 0)
    ORBSVCS_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) ImR: Server <%C> is shutting down.\n"),
                fqname));

  if (!info->is_mode(ImplementationRepository::PER_CLIENT))
    {
      this->pinger_.remove_server (info->ping_id());
      {
        AsyncAccessManager_ptr aam = this->find_aam (info->ping_id ());
        if (!aam.is_nil())
          {
            aam->server_is_shutting_down ();
          }
      }
    }
  info.edit ()->reset_runtime ();
  _tao_rh->server_is_shutting_down ();
}
void
ImR_Locator_i::remote_access_update (const char *name,
                                     ImplementationRepository::AAM_Status state)
{
  /*  ACE_GUARD (TAO_SYNCH_MUTEX, mon, this->lock_); */
  AsyncAccessManager_ptr aam (this->find_aam (name));
  if (aam.is_nil())
    {
      UpdateableServerInfo info (this->repository_, name);
      if (info.null ())
        {
          if (debug_ > 0)
            ORBSVCS_DEBUG ((LM_DEBUG,
                            ACE_TEXT ("(%P|%t) ImR: remote_acccess")
                            ACE_TEXT (" <%C> unregistered.\n"),
                            name));
          return;
        }
      aam = this->create_aam (info);
    }
  /* mon.release (); */
  aam->remote_state (state);
}
Esempio n. 7
0
int
Locator_Repository::unregister_if_address_reused (const ACE_CString& fqname,
                                                  const char* partial_ior,
                                                  ImR_Locator_i* imr_locator)

{
  if (this->opts_.debug() > 0)
  {
    ORBSVCS_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("(%P|%t)ImR: checking reuse address ")
                    ACE_TEXT ("for server \"%C\" ior \"%C\"\n"),
                    fqname.c_str(),
                    partial_ior));
  }

  ACE_CString key;
  Server_Info_Ptr si;

  Server_Info::fqname_to_key (fqname.c_str(), key);
  servers ().find (key, si);
  ACE_CString poa_name;
  ACE_CString server_id;
  if (si.null())
    {
      Server_Info::parse_id (fqname.c_str(), server_id, poa_name);
    }
  else
    {
      server_id = si->active_info ()->server_id;
      poa_name = si->active_info ()->poa_name;
    }

  Locator_Repository::SIMap::ENTRY* sientry = 0;
  Locator_Repository::SIMap::ITERATOR siit (servers ());
  for (; siit.next (sientry); siit.advance() )
  {
    Server_Info *info = sientry->int_id_->active_info ();

    if (this->opts_.debug() > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t)ImR: iterating - registered server")
                      ACE_TEXT ("\"%C:%C\" key = <%C> ior \"%C\"\n"), info->server_id.c_str(),
                      info->poa_name.c_str (), info->key_name_.c_str(), info->partial_ior.c_str ()));
    }
    bool same_server = info->server_id == server_id;
    if (same_server && (server_id.length () == 0))
      {
        same_server = info->poa_name == poa_name;
      }
    if (info->partial_ior == partial_ior && !same_server)
      {
        if (this->opts_.debug() > 0)
          {
            ORBSVCS_DEBUG ((LM_DEBUG,
                            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());
        AsyncAccessManager_ptr aam = imr_locator->find_aam (info->key_name_.c_str ());
        if (!aam.is_nil())
          {
            aam->server_is_shutting_down ();
          }
        info->reset_runtime ();
      }
  }

  return 0;
}
void
ImR_Locator_i::kill_server
(ImplementationRepository::AMH_AdministrationExtResponseHandler_ptr _tao_rh,
 const char * name,
 CORBA::Short signum)
{
  Server_Info_Ptr si;
  if (!this->get_info_for_name (name, si))
    {
      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;
    }

  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;
   }
  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;
    }
  if (!actext->kill_server (si->key_name_.c_str(), si->pid, signum))
    {
      CORBA::Exception *ex =
        new ImplementationRepository::CannotComplete ("server not running");
      ImplementationRepository::AMH_AdministrationExtExceptionHolder h (ex);
      _tao_rh->kill_server_excep (&h);
    }
  else
    {
      _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::shutdown_server
(ImplementationRepository::AMH_AdministrationResponseHandler_ptr _tao_rh,
 const char* id)
{
  const CORBA::ULong TAO_MINOR_MASK = 0x00000f80;
  if (debug_ > 0)
    ORBSVCS_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) ImR: Shutting down server <%C>.\n"),
                id));

  UpdateableServerInfo info (this->repository_, id);
  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;
    }

  this->connect_server (info);

  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;
    }

  try
    {
      CORBA::Object_var obj = this->set_timeout_policy (info->active_info()->server.in (),
                                                        DEFAULT_SHUTDOWN_TIMEOUT);
      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 ();
        }
    }
  catch (const CORBA::TIMEOUT &ex)
    {
      info.edit ()->reset_runtime ();
      // Note : This is a good thing. It means we didn't waste our time waiting for
      // the server to finish shutting down.
      if (debug_ > 1)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      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;
    }
  catch (const CORBA::COMM_FAILURE& ex)
    {
      info.edit ()->reset_runtime ();
      if (debug_ > 1)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("ImR: COMM_FAILURE while waiting for <%C> shutdown.\n"),
                      id));
        }
      if (this->opts_->throw_shutdown_exceptions ())
        {
          ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
          _tao_rh->shutdown_server_excep (&h);
          return;
        }
    }
  catch (const CORBA::TRANSIENT& ex)
    {
      CORBA::ULong minor = ex.minor () & TAO_MINOR_MASK;
      if (minor != TAO_POA_DISCARDING && minor != TAO_POA_HOLDING)
        {
          info.edit ()->reset_runtime ();
        }
      if (debug_ > 1)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("ImR: TRANSIENT while waiting for <%C> shutdown.\n"),
                      id));
        }
      if (this->opts_->throw_shutdown_exceptions ())
        {
          ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
          _tao_rh->shutdown_server_excep (&h);
          return;
        }
    }
  catch (const CORBA::Exception &ex)
    {
      if (debug_ > 1)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%P|%t) ImR: Exception while shutting down <%C>\n"),
            id));
        }
      if (this->opts_->throw_shutdown_exceptions ())
        {
          ImplementationRepository::AMH_AdministrationExceptionHolder h (ex._tao_duplicate());
          _tao_rh->shutdown_server_excep (&h);
          return;
        }
    }

  _tao_rh->shutdown_server ();
}