示例#1
0
CORBA::Object_ptr
TAO_Trading_Loader::create_object (CORBA::ORB_ptr orb_ptr,
                                   int argc,
                                   ACE_TCHAR *argv[])
{
  // Duplicate the ORB
  CORBA::ORB_var orb = CORBA::ORB::_duplicate (orb_ptr);

  // Activating the poa manager
  this->orb_manager_.activate_poa_manager ();

  // Create a Trader Object and set its Service Type Repository.
  auto_ptr<TAO_Trader_Factory::TAO_TRADER> auto_trader (TAO_Trader_Factory::create_trader (argc, argv));

  this->trader_ = auto_trader;

  TAO_Support_Attributes_i &sup_attr =
    this->trader_->support_attributes ();

  TAO_Trading_Components_i &trd_comp =
    this->trader_->trading_components ();

  sup_attr.type_repos (this->type_repos_._this ());

  // The Spec says: return a reference to the Lookup interface from
  // the resolve_initial_references method.
  CosTrading::Lookup_ptr lookup =
    trd_comp.lookup_if ();

  this->ior_ =
    orb->object_to_string (lookup);

  // Parse the args
  if (this->parse_args (argc, argv) == -1)
    return CORBA::Object::_nil ();

  // Dump the ior to a file.
  if (this->ior_output_file_ != 0)
    {
      ACE_OS::fprintf (this->ior_output_file_,
                       "%s",
                       this->ior_.in ());
      ACE_OS::fclose (this->ior_output_file_);
    }

  CORBA::Object_var table_object =
    orb->resolve_initial_references ("IORTable");

  IORTable::Table_var adapter =
    IORTable::Table::_narrow (table_object.in ());

  if (CORBA::is_nil (adapter.in ()))
    {
      ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
    }
  else
    {
      adapter->bind ("TradingService",
                     this->ior_.in ());
    }

  if (this->federate_)
    {
      // Only become a multicast server if we're the only trader
      // on the multicast network.
      // @@ Could do other things. For example, every timeout
      // period try to federate again, but let's not hardcode that
      // policy.
      int rc = this->bootstrap_to_federation ();

      if (rc == -1)
        this->init_multicast_server ();
    }
  else
    this->init_multicast_server ();

  return CORBA::Object::_nil ();
}
示例#2
0
//////////////////
// Internal method
void
TAO::PG_Object_Group::distribute_iogr (void)
{
  // Check if the object group is configured to distribute
  if (!this->distribute_)
    return;

  // assume internals is locked
  CORBA::String_var iogr =
    this->orb_->object_to_string (this->reference_.in());

//  size_t n_rep = 0; // for dump_ior below
  for (MemberMap_Iterator it = this->members_.begin();
       it != this->members_.end ();
       ++it)
    {
      MemberInfo const * info = (*it).int_id_;
      //
      // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface
      // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_);
      // but it doesn work: error message at replica is:
      // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0]
      // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed
      // back to using _narrow
      PortableGroup::TAO_UpdateObjectGroup_var uog =
        PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ());
      if (!CORBA::is_nil (uog.in ()))
        {
          try
            {
              if (TAO_debug_level > 3)
                {
                  ORBSVCS_DEBUG ((LM_DEBUG,
                              "PG (%P|%t) -  Object_Group pushing "
                              "IOGR to %s member: %s@%s.\n",
                              (info->is_primary_ ? "Primary" : "Backup"),
                              this->role_.c_str (),
                              static_cast<const char *> (info->location_[0].id)
                              ));
                }
              //        dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr);
              //        CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in());
              //        dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior);
              uog->tao_update_object_group (iogr.in (),
                                            this->tagged_component_.object_group_ref_version,
                                            info->is_primary_);
            }
          catch (const CORBA::Exception&)
            {
              // we expect an exception
              // tao_update_object_group is not a real method
            }
        }
      else
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      "TAO::PG_Object_Group::distribute iogr can't "
                      "narrow member reference to "
                      "PortableGroup::TAO_UpdateObjectGroup.\n"
                      ));
        }
    }
}
示例#3
0
文件: AV_Core.cpp 项目: asdlei00/ACE
int
TAO_AV_Core::load_default_transport_factories (void)
{
  const char *udp_factory_str = "UDP_Factory";
  const char *tcp_factory_str = "TCP_Factory";

  TAO_AV_Transport_Factory *udp_factory = 0;
  TAO_AV_Transport_Item *udp_item = 0;

  udp_factory =
    ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_factory_str);
  if (udp_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "UDP Factory"));

      ACE_NEW_RETURN (udp_factory,
                      TAO_AV_UDP_Factory,
                      -1);
    }
  else udp_factory->ref_count = 1;

  ACE_NEW_RETURN (udp_item, TAO_AV_Transport_Item ("UDP_Factory"), -1);
  udp_item->factory (udp_factory);

  this->transport_factories_.insert (udp_item);

  TAO_AV_Transport_Factory *tcp_factory = 0;
  TAO_AV_Transport_Item *tcp_item = 0;

  tcp_factory =
    ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (tcp_factory_str);
  if (tcp_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "TCP Factory"));

      ACE_NEW_RETURN (tcp_factory,
                      TAO_AV_TCP_Factory,
                          -1);
    }
  else tcp_factory->ref_count = 1;

  ACE_NEW_RETURN (tcp_item, TAO_AV_Transport_Item ("TCP_Factory"), -1);
  tcp_item->factory (tcp_factory);

  this->transport_factories_.insert (tcp_item);

#if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
  const char *udp_qos_factory_str = "UDP_QoS_Factory";

  TAO_AV_Transport_Factory *udp_qos_factory = 0;
  TAO_AV_Transport_Item *udp_qos_item = 0;

  udp_qos_factory =
        ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (udp_qos_factory_str);
  if (udp_qos_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "UDP QoS Factory"));

          ACE_NEW_RETURN (udp_qos_factory,
                          TAO_AV_UDP_QoS_Factory,
                          -1);
    }
  else udp_qos_factory->ref_count = 1;

  ACE_NEW_RETURN (udp_qos_item,
                  TAO_AV_Transport_Item ("UDP_QoS_Factory"),
                  -1);

  udp_qos_item->factory (udp_qos_factory);

  this->transport_factories_.insert (udp_qos_item);
#endif /* ACE_HAS_RAPI || ACE_HAS_WINSOCK2_GQOS */

#if defined ACE_HAS_SCTP
  const char *sctp_seq_factory_str = "SCTP_SEQ_Factory";

  TAO_AV_Transport_Factory *sctp_seq_factory = 0;
  TAO_AV_Transport_Item *sctp_seq_item = 0;

  sctp_seq_factory =
        ACE_Dynamic_Service<TAO_AV_Transport_Factory>::instance (sctp_seq_factory_str);
  if (sctp_seq_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "SCTP SEQ Factory"));

      ACE_NEW_RETURN (sctp_seq_factory,
                      TAO_AV_SCTP_SEQ_Factory,
                      -1);
    }
  else sctp_seq_factory->ref_count = 1;

  ACE_NEW_RETURN (sctp_seq_item,
                  TAO_AV_Transport_Item ("SCTP_SEQ_Factory"),
                  -1);

  sctp_seq_item->factory (sctp_seq_factory);

  this->transport_factories_.insert (sctp_seq_item);
#endif /* ACE_HAS_SCTP */

  return 0;
}
示例#4
0
void
TAO_ECG_CDR_Message_Sender::send_fragment (const ACE_INET_Addr &addr,
                                           CORBA::ULong request_id,
                                           CORBA::ULong request_size,
                                           CORBA::ULong fragment_size,
                                           CORBA::ULong fragment_offset,
                                           CORBA::ULong fragment_id,
                                           CORBA::ULong fragment_count,
                                           iovec iov[],
                                           int iovcnt)
{
  CORBA::ULong header[TAO_ECG_CDR_Message_Sender::ECG_HEADER_SIZE
                     / sizeof(CORBA::ULong)
                     + ACE_CDR::MAX_ALIGNMENT];
  char* buf = reinterpret_cast<char*> (header);
  TAO_OutputCDR cdr (buf, sizeof(header));
  cdr.write_boolean (TAO_ENCAP_BYTE_ORDER);
  // Insert some known values in the padding bytes, so we can smoke
  // test the message on the receiving end.
  cdr.write_octet ('A'); cdr.write_octet ('B'); cdr.write_octet ('C');
  cdr.write_ulong (request_id);
  cdr.write_ulong (request_size);
  cdr.write_ulong (fragment_size);
  cdr.write_ulong (fragment_offset);
  cdr.write_ulong (fragment_id);
  cdr.write_ulong (fragment_count);
  CORBA::Octet padding[4];


  // MRH
  if (checksum_)
  {
    // Compute CRC
     iov[0].iov_base = cdr.begin ()->rd_ptr ();
     iov[0].iov_len  = cdr.begin ()->length ();
     unsigned int crc = 0;
     unsigned char *crc_parts = (unsigned char *)(&crc);
     if (iovcnt > 1)
       {
         crc = ACE::crc32 (iov, iovcnt);
         crc = ACE_HTONL (crc);
       }
     for (int cnt=0; cnt<4; ++cnt)
       {
         padding[cnt] = crc_parts[cnt];
       }
   }
   else
   {
     for (int cnt=0; cnt<4; ++cnt)
     {
       padding[cnt] = 0;
     }
   }
   //End MRH
  cdr.write_octet_array (padding, 4);

  iov[0].iov_base = cdr.begin ()->rd_ptr ();
  iov[0].iov_len  = cdr.begin ()->length ();

  ssize_t n = this->dgram ().send (iov,
                                   iovcnt,
                                   addr);
  size_t expected_n = 0;
  for (int i = 0; i < iovcnt; ++i)
    expected_n += iov[i].iov_len;
  if (n > 0 && size_t(n) != expected_n)
    {
      ORBSVCS_ERROR ((LM_ERROR, ("Sent only %d out of %d bytes "
                              "for mcast fragment.\n"),
                  n,
                  expected_n));
    }

  if (n == -1)
    {
      if (errno == EWOULDBLOCK)
        {
          ORBSVCS_ERROR ((LM_ERROR, "Send of mcast fragment failed (%m).\n"));
          // @@ TODO Use a Event Channel specific exception
          throw CORBA::COMM_FAILURE ();
        }
      else
        {
          ORBSVCS_DEBUG ((LM_WARNING, "Send of mcast fragment blocked (%m).\n"));
        }
    }
  else if (n == 0)
    {
      ORBSVCS_DEBUG ((LM_WARNING, "EOF on send of mcast fragment (%m).\n"));
    }
}
示例#5
0
void
TAO::PG_Object_Group::add_member (const PortableGroup::Location & the_location,
                                  CORBA::Object_ptr member)

{
  ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);

  if (CORBA::is_nil (member))
    {
      if (TAO_debug_level > 3)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("%T %n (%P|%t) - TAO::PG_Object_Group::add_member")
                      ACE_TEXT ("Can't add a null member to object group\n")
                      ));
        }
      throw PortableGroup::ObjectNotAdded ();
    }

  /////////////////////////////////////////
  // Convert the new member to a string IOR
  // This keeps a clean IOR (not an IOGR!)
  // while we add it to a group.  We need a
  // IORs, not IOGRs to send new IOGRs out
  // to replicas.

  // Verify that the member is not using V1.0 profiles
  // since IIOP V1.0 does not support tagged components
  const TAO_MProfile &member_profiles =
    member->_stubobj ()->base_profiles ();
  CORBA::ULong member_profile_count =
    member_profiles.profile_count ();
  if (member_profile_count > 0)
    {
      const TAO_GIOP_Message_Version & version =
        member_profiles.get_profile (0)->version ();
      if (version.major_version () == 1 &&
          version.minor_version () == 0)
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT ("%T %n (%P|%t) - ")
                          ACE_TEXT ("Can't add member because first profile ")
                          ACE_TEXT ("is IIOP version 1.0, which does not ")
                          ACE_TEXT ("support tagged components.\n")
                          ));
            }
          throw PortableGroup::ObjectNotAdded ();
        }
    }

  CORBA::String_var member_ior_string =
    orb_->object_to_string (member);

  PortableGroup::ObjectGroup_var new_reference;
  try {
    new_reference =
      this->add_member_to_iogr (member);
  }
  catch (const TAO_IOP::Duplicate&)
    {
      throw PortableGroup::MemberAlreadyPresent ();
    }
  catch (const TAO_IOP::Invalid_IOR&)
    {
      throw PortableGroup::ObjectNotAdded ();
    }
  catch (...)
    {
      throw;
    }

  if (CORBA::is_nil (new_reference.in ()))
    throw PortableGroup::ObjectNotAdded ();

  // Convert new member back to a (non group) ior.
  CORBA::Object_var member_ior =
    this->orb_->string_to_object (member_ior_string.in ());

  MemberInfo * info = 0;
  ACE_NEW_THROW_EX (info,
                    MemberInfo (member_ior.in (),
                                the_location),
                    CORBA::NO_MEMORY());

  if (this->members_.bind (the_location, info) != 0)
    {
      delete info;

      // @@ Dale why this is a NO MEMORY exception?
      throw CORBA::NO_MEMORY();
    }

  this->reference_ = new_reference; // note var-to-var assignment does
                                    // a duplicate

  if (this->increment_version ())
    {
      this->distribute_iogr ();
    }
  else
    { // Issue with incrementing the version

      if (TAO_debug_level > 6)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("PG (%P|%t) Issue incrementing the ")
                      ACE_TEXT ("version in Object_Group add_member\n")));
        }
      // Must unbind the new member and delete it.
      if (this->members_.unbind (the_location, info) == 0)
        delete info;
      throw PortableGroup::ObjectNotAdded ();
    }

  if (TAO_debug_level > 6)
  {
    ORBSVCS_DEBUG ((LM_DEBUG,
      ACE_TEXT("PG (%P|%t) exit Object_Group add_member\n")));
  }
}
示例#6
0
void TAO::FT_FaultNotifier_i::disconnect_consumer (
    FT::FaultNotifier::ConsumerId connection
)
{
    METHOD_ENTRY(TAO::FT_FaultNotifier_i::disconnect_consumer);

    size_t index = static_cast<size_t> (connection);
    if (index < this->proxy_infos_.size())
    {
        ProxyInfo & info = this->proxy_infos_[index];
        if (CORBA::is_nil(info.proxyVar_.in ()) )
        {
            throw CosEventComm::Disconnected();
        }
        else
        {
            ::CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxySupplier
                = ::CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(info.proxyVar_.in ());
            if (! CORBA::is_nil (proxySupplier.in ()))
            {
                proxySupplier->disconnect_structured_push_supplier ();
                info.proxyVar_ = ::CosNotifyChannelAdmin::ProxySupplier::_nil();
            }
            else
            {
                ::CosNotifyChannelAdmin::SequenceProxyPushSupplier_var proxySupplier
                    = ::CosNotifyChannelAdmin::SequenceProxyPushSupplier::_narrow(info.proxyVar_.in ());
                if (! CORBA::is_nil (proxySupplier.in ()))
                {
                    proxySupplier->disconnect_sequence_push_supplier ();
                    info.proxyVar_ = ::CosNotifyChannelAdmin::ProxySupplier::_nil();
                }
                else
                {
                    ORBSVCS_ERROR((LM_ERROR,
                                   "%T %n (%P|%t) Unexpected proxy supplier type\n"
                                  ));
                    throw CosEventComm::Disconnected();
                }
            }
        }
    }
    else
    {
        throw CosEventComm::Disconnected();
    }

    this->consumer_disconnects_ += 1;
    if (this->quit_on_idle_)
    {
        if (! this->quitting_
                && this->consumer_connects_ == this->consumer_disconnects_)
        {
            ORBSVCS_ERROR((LM_ERROR,
                           "FaultNotifier (%P|%t) quit on idle: connects %d, disconnects %d\n",
                           static_cast<unsigned int> (this->consumer_connects_),
                           static_cast<unsigned int> (this->consumer_disconnects_)
                          ));
            this->poa_->deactivate_object (this->object_id_.in ());
            this->quitting_ = 1;
        }
    }

    METHOD_RETURN(TAO::FT_FaultNotifier_i::disconnect_consumer);
}
示例#7
0
void TAO::Fault_Detector_i::notify()
{
  CosNotification::StructuredEvent_var vEvent;
  ACE_NEW_NORETURN(vEvent, CosNotification::StructuredEvent );
  if (vEvent.ptr() != 0)
  {
    CORBA::ULong length = 2;
    if( this->object_type_ != 0)
    {
      length = 3;
      if (this->group_id_!= 0)
      {
        length = 4;
      }
    }

    vEvent->header.fixed_header.event_type.domain_name = FT::FT_EVENT_TYPE_DOMAIN;
    vEvent->header.fixed_header.event_type.type_name = FT::FT_EVENT_TYPE_NAME;
    vEvent->filterable_data.length(length);
    vEvent->filterable_data[0].name = FT::FT_DOMAIN_ID;
    (vEvent->filterable_data[0].value) <<= this->domain_id_;
    vEvent->filterable_data[1].name = FT::FT_LOCATION;
    (vEvent->filterable_data[1].value) <<= this->object_location_;
    if (this->object_type_!= 0)
    {
      vEvent->filterable_data[2].name = FT::FT_TYPE_ID;
      (vEvent->filterable_data[2].value) <<= this->object_type_;
      if (this->group_id_!= 0)
      {
        vEvent->filterable_data[3].name = FT::FT_GROUP_ID;
        vEvent->filterable_data[3].value <<= this->group_id_;
      }
    }
    try
    {
      if (TAO_debug_level > 5)
      {
        ORBSVCS_ERROR ((LM_ERROR,
        "call Fault Detector push Structured Event.\n"
        ));
      }
      this->notifier_->push_structured_fault(vEvent.in());
      if (TAO_debug_level > 5)
      {

        ORBSVCS_ERROR ((LM_ERROR,
        "return from Fault Detector push Structured Event.\n"
        ));
      }
    }
    catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Fault Detector cannot send notification.");
    }
  }
  else
  {
    ORBSVCS_ERROR ((LM_ERROR,
      "Fault Detector cannot create Structured Event.\n"
      ));
  }
}
示例#8
0
TAO_Transport *
TAO::IIOP_SSL_Connector::make_connection (
  TAO::Profile_Transport_Resolver *r,
  TAO_Transport_Descriptor_Interface &desc,
  ACE_Time_Value *max_wait_time)
{
  TAO_IIOP_Endpoint *iiop_endpoint =
    dynamic_cast<TAO_IIOP_Endpoint *> (desc.endpoint ());

  if (iiop_endpoint == 0)
    return 0;

  const ACE_INET_Addr &remote_address =
    iiop_endpoint->object_addr ();

  if (TAO_debug_level > 4)
    ORBSVCS_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) IIOP_SSL_Connector::connect ")
                ACE_TEXT ("making a new connection\n")));

  // Get the right synch options
  ACE_Synch_Options synch_options;

  this->active_connect_strategy_->synch_options (max_wait_time, synch_options);

  // If we don't need to block for a transport just set the timeout to
  // be zero.
  ACE_Time_Value tmp_zero (ACE_Time_Value::zero);
  if (!r->blocked_connect ())
    {
      synch_options.timeout (ACE_Time_Value::zero);
      max_wait_time = &tmp_zero;
    }


  IIOP_SSL_Connection_Handler *svc_handler = 0;

  // Connect.
  int result =
    this->base_connector_.connect (svc_handler, remote_address, synch_options);

  // Make sure that we always do a remove_reference
  ACE_Event_Handler_var svc_handler_auto_ptr (svc_handler);

  TAO_Transport *transport =
    svc_handler->transport ();

  if (result == -1)
    {
      // No immediate result, wait for completion
      if (errno == EWOULDBLOCK)
        {
          // Try to wait until connection completion. Incase we block, then we
          // get a connected transport or not. In case of non block we get
          // a connected or not connected transport
          if (!this->wait_for_connection_completion (r,
                                                     desc,
                                                     transport,
                                                     max_wait_time))
            {
              if (TAO_debug_level > 2)
                ORBSVCS_ERROR ((LM_ERROR, "TAO (%P|%t) - IIOP_SSL_Connector::"
                                      "make_connection, "
                                      "wait for completion failed\n"));
            }
        }
      else
        {
          // Transport is not usable
          transport = 0;
        }
    }

  // In case of errors transport is zero
  if (transport == 0)
    {
      // Give users a clue to the problem.
      if (TAO_debug_level)
        {
          ORBSVCS_DEBUG ((LM_ERROR,
                      "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
                      "connection to <%s:%d> failed (%p)\n",
                      iiop_endpoint->host (), iiop_endpoint->port (),
                      "errno"));
        }

      return 0;
    }

  if (svc_handler->keep_waiting (this->orb_core ()->leader_follower ()))
    {
      svc_handler->connection_pending ();
    }

  // At this point, the connection has be successfully connected.
  // #REFCOUNT# is one.
  if (TAO_debug_level > 2)
    ORBSVCS_DEBUG ((LM_DEBUG,
                "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
                "new connection to <%s:%d> on Transport[%d]\n",
                iiop_endpoint->host (), iiop_endpoint->port (),
                svc_handler->peer ().get_handle ()));

  // Add the handler to Cache
  int retval =
    this->orb_core ()->lane_resources ().transport_cache ().cache_transport (
      &desc,
      transport);

  // Failure in adding to cache.
  if (retval == -1)
    {
      // Close the handler.
      svc_handler->close ();

      if (TAO_debug_level > 0)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      "TAO (%P|%t) - IIOP_SSL_Connector::make_connection, "
                      "could not add the new connection to cache\n"));
        }

      return 0;
    }

  if (transport->is_connected () &&
      transport->wait_strategy ()->register_handler () != 0)
    {
      // Registration failures.

      // Purge from the connection cache, if we are not in the cache, this
      // just does nothing.
      (void) transport->purge_entry ();

      // Close the handler.
      (void) transport->close_connection ();

      if (TAO_debug_level > 0)
        ORBSVCS_ERROR ((LM_ERROR,
                    "TAO (%P|%t) - IIOP_SSL_Connector [%d]::make_connection, "
                    "could not register the transport "
                    "in the reactor.\n",
                    transport->id ()));

      return 0;
    }

  svc_handler_auto_ptr.release ();
  return transport;
}
示例#9
0
int
TAO_MIOP_Resource_Factory::init (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("TAO_MIOP_Resource_Factory::init");

  for (int curarg = 0; curarg < argc; ++curarg)
    {
      if (ACE_OS::strcasecmp (argv[curarg],
                              ACE_TEXT ("-ORBFragmentsCleanupStrategy")) == 0)
        {
          if (++curarg < argc)
            {
              ACE_TCHAR* name = argv[curarg];

              if (ACE_OS::strcasecmp (name,
                                      ACE_TEXT ("delay")) == 0)
                {
                  this->fragments_cleanup_strategy_type_ =
                    TAO_MIOP_CLEANUP_TIME_BOUND;
                }
              else if (ACE_OS::strcasecmp (name,
                                           ACE_TEXT ("number")) == 0)
                {
                  this->fragments_cleanup_strategy_type_ =
                    TAO_MIOP_CLEANUP_NUMBER_BOUND;
                }
              else if (ACE_OS::strcasecmp (name,
                                           ACE_TEXT ("memory")) == 0)
                {
                  this->fragments_cleanup_strategy_type_ =
                    TAO_MIOP_CLEANUP_MEMORY_BOUND;
                }
              else
                ORBSVCS_DEBUG ((LM_ERROR,
                            ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                            ACE_TEXT ("-ORBFragmentsCleanupStrategy %s is unknown.\n"),
                            name));
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBFragmentsCleanupStrategy missing type.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBFragmentsCleanupBound")) == 0)
        {
          if (++curarg < argc)
            this->fragments_cleanup_bound_ = ACE_OS::atoi (argv[curarg]);
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBFragmentsCleanupBound missing value.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBMaxFragments")) == 0)
        {
          if (++curarg < argc)
            {
              int const max= ACE_OS::atoi (argv[curarg]);
              if (max < 0)
                {
                  ORBSVCS_ERROR ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("-ORBMaxFragments %d ")
                              ACE_TEXT ("is invalid (using %u).\n"),
                              max,
                              TAO_DEFAULT_MIOP_MAX_FRAGMENTS));
                  this->max_fragments_ = TAO_DEFAULT_MIOP_MAX_FRAGMENTS;
                }
              else
                this->max_fragments_ = static_cast<u_long> (max);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBMaxFragments missing limit.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBMaxFragmentSize")) == 0)
        {
          if (++curarg < argc)
            {
              int const size= ACE_OS::atoi (argv[curarg]);
              if (size < static_cast<int> (MIOP_MAX_HEADER_SIZE) ||
                  size > static_cast<int> (MIOP_MAX_DGRAM_SIZE)    )
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("-ORBMaxFragmentSize %d is not within ")
                              ACE_TEXT ("range %u to %u (using %u).\n"),
                              size,
                              MIOP_MAX_HEADER_SIZE,
                              MIOP_MAX_DGRAM_SIZE,
                              TAO_DEFAULT_MIOP_FRAGMENT_SIZE));
                  this->max_fragment_size_ = TAO_DEFAULT_MIOP_FRAGMENT_SIZE;
                }
              else
                this->max_fragment_size_ = static_cast<u_long> (size);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBMaxFragmentSize missing limit.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBMaxFragmentRate")) == 0)
        {
          if (++curarg < argc)
            {
              int const tx_time= ACE_OS::atoi (argv[curarg]);
              if (tx_time <= 0)
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("-ORBMaxFragmentRate %d is invalid ")
                              ACE_TEXT ("(using -ORBMaxFragmentSize in micro seconds).\n"),
                              tx_time));
                  this->max_fragment_rate_= 0u; // Zero uses configured max_fragment_size_
                }
              else
                this->max_fragment_rate_= static_cast<u_long> (tx_time);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBMaxFragmentRate missing micro-seconds.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSendHighWaterMark")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSendHiWaterMark")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSendHWM")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSndHighWaterMark")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSndHiWaterMark")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSndHWM")) == 0)
        {
          if (++curarg < argc)
            {
              int const hwm= ACE_OS::atoi (argv[curarg]);
              if (hwm <= 0)
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("%s %d is invalid ")
                              ACE_TEXT ("(using actual -ORBSndSock size).\n"),
                              argv[curarg-1],
                              hwm,
                              TAO_DEFAULT_MIOP_MAX_FRAGMENTS));
                  this->send_hi_water_mark_ = 0u; // Zero sets this to actual -ORBSndSock
                }
              else
                this->send_hi_water_mark_ = static_cast<u_long> (hwm);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("%s missing limit.\n"),
                        argv[curarg-1]));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSndSock")) == 0)
        {
          if (++curarg < argc)
            {
              int const bytes= ACE_OS::atoi (argv[curarg]);
              if (bytes <= 0)
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("-ORBSndSock %d is invalid.\n"),
                              bytes));
                  this->send_buffer_size_= 0u; // Zero is unspecified
                }
              else
                this->send_buffer_size_= static_cast<u_long> (bytes);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBSndSock missing size in bytes.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBRcvSock")) == 0)
        {
          if (++curarg < argc)
            {
              int const bytes= ACE_OS::atoi (argv[curarg]);
              if (bytes <= 0)
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                              ACE_TEXT ("-ORBRcvSock %d is invalid.\n"),
                              bytes));
                  this->receive_buffer_size_= 0u; // Zero is unspecified
                }
              else
                this->receive_buffer_size_= static_cast<u_long> (bytes);
            }
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("-ORBRcvSock missing size in bytes.\n")));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSendThrottling")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBSendThrottle")) == 0)
        {
          if (++curarg < argc)
            this->enable_throttling_= static_cast<bool> (ACE_OS::atoi (argv[curarg]));
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("%s missing 0 or 1 parameter.\n"),
                        argv[curarg-1]));
        }
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBEagerDequeueing")) == 0 ||
               ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT ("-ORBEagerDequeue")) == 0)
        {
          if (++curarg < argc)
            this->enable_eager_dequeue_= static_cast<bool> (ACE_OS::atoi (argv[curarg]));
          else
            ORBSVCS_DEBUG ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory ")
                        ACE_TEXT ("%s missing 0 or 1 parameter.\n"),
                        argv[curarg-1]));
        }
      else if (ACE_OS::strncmp (argv[curarg], ACE_TEXT ("-ORB"), 4) == 0)
        {
          // Can we assume there is an argument after the option?
          // ++curarg;
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory - ")
                      ACE_TEXT ("unknown option <%s>.\n"),
                      argv[curarg]));
        }
      else
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - MIOP_Resource_Factory - ")
                      ACE_TEXT ("ignoring option <%s>.\n"),
                      argv[curarg]));
        }
    }

  return 0;
}
示例#10
0
 // virtual
 int
 XML_Topology_Factory::init (int argc, ACE_TCHAR *argv[])
 {
   int result = 0;
   bool verbose = false;
   for (int narg = 0; narg < argc; ++narg)
   {
     ACE_TCHAR * av = argv[narg];
     if (ACE_OS::strcasecmp (av, ACE_TEXT("-v")) == 0)
     {
       verbose = true;
       ORBSVCS_DEBUG ((LM_DEBUG,
         ACE_TEXT ("(%P|%t) Standard_Event_Persistence: -verbose\n")
         ));
     }
     else if (ACE_OS::strcasecmp (av, ACE_TEXT("-base_path")) == 0 && narg + 1 < argc)
     {
       this->save_base_path_ = argv[narg + 1];
       this->load_base_path_ = argv[narg + 1];
       if (TAO_debug_level > 0 || verbose)
       {
         ORBSVCS_DEBUG ((LM_DEBUG,
           ACE_TEXT ("(%P|%t) XML_TopologyFactory: Setting -base_path: %s\n"),
           this->save_base_path_.c_str ()
         ));
       }
       narg += 1;
     }
     else if (ACE_OS::strcasecmp (av, ACE_TEXT("-save_base_path")) == 0 && narg + 1 < argc)
     {
       this->save_base_path_ = argv[narg + 1];
       if (TAO_debug_level > 0 || verbose)
       {
         ORBSVCS_DEBUG ((LM_DEBUG,
           ACE_TEXT ("(%P|%t) XML_TopologyFactory: Setting -save_base_path: %s\n"),
           this->save_base_path_.c_str ()
         ));
       }
       narg += 1;
     }
     else if (ACE_OS::strcasecmp (av, ACE_TEXT("-load_base_path")) == 0 && narg + 1 < argc)
     {
       this->load_base_path_ = argv[narg + 1];
       if (TAO_debug_level > 0 || verbose)
       {
         ORBSVCS_DEBUG ((LM_DEBUG,
           ACE_TEXT ("(%P|%t) XML_TopologyFactory: Setting -load_base_path: %s\n"),
           this->load_base_path_.c_str ()
         ));
       }
       narg += 1;
     }
     else if (ACE_OS::strcasecmp (av, ACE_TEXT("-backup_count")) == 0 && narg + 1 < argc)
     {
       this->backup_count_ = ACE_OS::atoi(argv[narg + 1]);
       if (TAO_debug_level > 0 || verbose)
       {
         ORBSVCS_DEBUG ((LM_DEBUG,
           ACE_TEXT ("(%P|%t) XML_TopologyFactory: Setting -file_count: %d\n"),
           this->backup_count_
         ));
       }
       narg += 1;
     }
     else if (ACE_OS::strcasecmp (av, ACE_TEXT("-no_timestamp")) == 0)
     {
       this->timestamp_ = false;
       if (TAO_debug_level > 0 || verbose)
       {
         ORBSVCS_DEBUG ((LM_DEBUG,
           ACE_TEXT ("(%P|%t) XML_TopologyFactory: Setting -no_timestamp\n")
         ));
       }
     }
     else
     {
       ORBSVCS_ERROR ((LM_ERROR,
         ACE_TEXT ("(%P|%t) Unknown parameter to XML Topology Factory: %s\n"),
         argv[narg]
         ));
       result = -1;
     }
   }
   return result;
 }
示例#11
0
文件: sfp.cpp 项目: asdlei00/ACE
TAO_SFP_Base::TAO_SFP_Base (void)
{
  TAO_OutputCDR output_cdr;
  flowProtocol::frameHeader frame_header;
  flowProtocol::fragment fragment;
  flowProtocol::credit credit;
  flowProtocol::Start start;
  flowProtocol::StartReply start_reply;

  // fill in the default frameHeader fields.
  frame_header.magic_number [0] = '=';
  frame_header.magic_number [1] = 'S';
  frame_header.magic_number [2] = 'F';
  frame_header.magic_number [3] = 'P';
  frame_header.flags = TAO_ENCAP_BYTE_ORDER;
  output_cdr.reset ();
  if (!(output_cdr << frame_header))
    {
      ORBSVCS_ERROR ((LM_ERROR, "TAO_SFP constructor\n"));
      return;
    }

  frame_header_len = static_cast<u_int> (output_cdr.total_length ());
  // fill in the default fragment message fields.
  fragment.magic_number [0] = 'F';
  fragment.magic_number [1] = 'R';
  fragment.magic_number [2] = 'A';
  fragment.magic_number [3] = 'G';
  output_cdr.reset ();
  if (!(output_cdr << fragment))
    {
      ORBSVCS_ERROR ((LM_ERROR, "TAO_SFP constructor\n"));
      return;
    }

  fragment_len = static_cast<u_int> (output_cdr.total_length ());
  // fill in the default Start message fields.
  start.magic_number [0] = '=';
  start.magic_number [1] = 'S';
  start.magic_number [2] = 'T';
  start.magic_number [3] = 'A';
  start.major_version = TAO_SFP_Base::TAO_SFP_MAJOR_VERSION;
  start.minor_version = TAO_SFP_Base::TAO_SFP_MINOR_VERSION;
  start.flags = 0;
  output_cdr.reset ();
  if (!(output_cdr << start))
    {
      ORBSVCS_ERROR ((LM_ERROR, "TAO_SFP constructor\n"));
      return;
    }

  start_len = static_cast<u_int> (output_cdr.total_length ());
  // fill in the default StartReply message fields.
  start_reply.magic_number [0] = '=';
  start_reply.magic_number [1] = 'S';
  start_reply.magic_number [2] = 'T';
  start_reply.magic_number [3] = 'R';
  start_reply.flags = 0;
  output_cdr.reset ();
  if (!(output_cdr << start_reply))
    {
      ORBSVCS_ERROR ((LM_ERROR, "TAO_SFP constructor\n"));
      return;
    }

  start_reply_len = static_cast<u_int> (output_cdr.total_length ());

  // fill in the default Credit message fields.
  credit.magic_number [0] = '=';
  credit.magic_number [1] = 'C';
  credit.magic_number [2] = 'R';
  credit.magic_number [3] = 'E';
  output_cdr.reset ();

  if (!(output_cdr << credit))
    {
      ORBSVCS_ERROR ((LM_ERROR, "TAO_SFP constructor\n"));
      return;
    }
  credit_len = static_cast<u_int> (output_cdr.total_length ());
}
CORBA::Boolean
TAO_LB_ObjectReferenceFactory::find_object_group (
  const char * repository_id,
  CORBA::ULong & index,
  PortableGroup::ObjectGroup_out object_group)
{
  if (!this->load_managed_object (repository_id, index))
    return false;

  PortableGroup::ObjectGroup_var group;
  if (this->table_.find (repository_id, group) != 0)
    {
      if (ACE_OS::strcasecmp (this->object_groups_[index],
                              "CREATE") == 0)
        {
          PortableGroup::Criteria criteria (1);
          criteria.length (1);

          PortableGroup::Property & property = criteria[0];
          property.nam.length (1);

          property.nam[0].id =
            CORBA::string_dup ("org.omg.PortableGroup.MembershipStyle");

          // Configure for application-controlled membership.
          PortableGroup::MembershipStyleValue msv =
            PortableGroup::MEMB_APP_CTRL;
          property.val <<= msv;

          PortableGroup::GenericFactory::FactoryCreationId_var fcid;

          group =
            this->lm_->create_object (repository_id,
                                      criteria,
                                      fcid.out ());

          CORBA::ULong const len = this->fcids_.size ();
          this->fcids_.size (len + 1); // Incremental growth.  Yuck!
          this->fcids_[len] = fcid;
        }
      else
        {
          group =
            this->orb_->string_to_object (this->object_groups_[index]);
        }

      if (this->table_.bind (repository_id, group) != 0)
        {
          if (TAO_debug_level > 0)
            ORBSVCS_ERROR ((LM_ERROR,
                        "TAO_LB_ObjectReferenceFactory::"
                        "find_object_group - "
                        "Couldn't bind object group reference.\n"));

          throw CORBA::INTERNAL ();
        }

      object_group = group._retn ();
    }

  return 1;
}
示例#13
0
/* static */
int
XML_Backing_Store::load_file (const ACE_TString& filename,
                              ACEXML_DefaultHandler& xml_handler,
                              unsigned int debug,
                              FILE* open_file)
{
  // xml input source will take ownership
  ACEXML_FileCharStream* fstm;
  ACE_NEW_RETURN (fstm,
                  ACEXML_FileCharStream,
                  -1);

  int err;
  // use the open_file stream if it is provided
  if (open_file != 0)
    err = fstm->use_stream(open_file,
                           filename.c_str());
  else
    err = fstm->open (filename.c_str());

  if (debug > 9)
    {
      ORBSVCS_DEBUG ((LM_INFO, ACE_TEXT ("load %s%C\n"), filename.c_str(),
                 ((err == 0) ? ACE_TEXT ("")
                  : ACE_TEXT (" (file doesn't exist)"))));
    }

  if (err != 0)
    {
      delete fstm;
      return err;
    }

  ACEXML_Parser parser;

  // InputSource takes ownership
  ACEXML_InputSource input (fstm);

  parser.setContentHandler (&xml_handler);
  parser.setDTDHandler (&xml_handler);
  parser.setErrorHandler (&xml_handler);
  parser.setEntityResolver (&xml_handler);

  try
    {
      parser.parse (&input);
    }
    catch ( const ACEXML_SAXParseException* sax_ex)
    {
      ORBSVCS_ERROR ((LM_ERROR,
        ACE_TEXT ("Error during load of ImR persistence xml file (%s)."),
        filename.c_str()));
      sax_ex->print ();
      return -1;
    }
    catch (const ACEXML_Exception& ex)
    {
      ORBSVCS_ERROR ((LM_ERROR,
        ACE_TEXT ("Error during load of ImR persistence xml file (%s)."),
        filename.c_str()));
      ex.print ();
      return -1;
    }



  return 0;
}
示例#14
0
int
TAO_CosNotify_Service::init (int argc, ACE_TCHAR *argv[])
{
  ACE_Arg_Shifter arg_shifter (argc, argv);

  const ACE_TCHAR *current_arg = 0;

  // Default to an all reactive system.
  int ec_threads = 0;
  int consumer_threads = 0;
  int supplier_threads = 0;

  bool task_per_proxy = false;

  TAO_Notify_Properties *properties = TAO_Notify_PROPERTIES::instance();

  while (arg_shifter.is_anything_left ())
    {
      if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTDispatching")) == 0)
        {
          arg_shifter.consume_arg ();
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -MTDispatching option has been deprecated, use -DispatchingThreads\n")));
        }
      else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-DispatchingThreads"))))
        {
          consumer_threads += ACE_OS::atoi (current_arg);
          arg_shifter.consume_arg ();
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTSourceEval")) == 0)
        {
          arg_shifter.consume_arg ();
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -MTSourceEval option has been deprecated, use -SourceThreads\n")));
        }
      else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-SourceThreads"))))
        {
          supplier_threads += ACE_OS::atoi (current_arg);
          arg_shifter.consume_arg ();
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTLookup")) == 0)
        {
          arg_shifter.consume_arg ();
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -MTLookup option has been deprecated, use -SourceThreads\n")));
        }
      else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-LookupThreads"))))
        {
          supplier_threads += ACE_OS::atoi (current_arg);
          arg_shifter.consume_arg ();
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -LookupThreads option has been deprecated, use -SourceThreads\n")));
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-MTListenerEval")) == 0)
        {
          arg_shifter.consume_arg ();
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -MTListenerEval option has been deprecated, use -DispatchingThreads\n")));
        }
      else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ListenerThreads"))))
        {
          // Since this option is always added to consumer_threads, we'll
          // deprecate it in favor of that option.
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%P|%t) The -ListenerThreads option has been deprecated, use -DispatchingThreads\n")));
          consumer_threads += ACE_OS::atoi (current_arg);
          arg_shifter.consume_arg ();
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AsynchUpdates")) == 0)
        {
          arg_shifter.consume_arg ();

          properties->asynch_updates (1);
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-NoUpdates")) == 0)
        {
          arg_shifter.consume_arg ();

          properties->updates (0);
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AllocateTaskperProxy")) == 0)
        {
          task_per_proxy = true;
          arg_shifter.consume_arg ();
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-UseSeparateDispatchingORB")) == 0)
        {
          current_arg = arg_shifter.get_the_parameter
                                (ACE_TEXT("-UseSeparateDispatchingORB"));
          if (current_arg != 0 &&
              (ACE_OS::strcmp(ACE_TEXT ("0"), current_arg) == 0 ||
               ACE_OS::strcmp(ACE_TEXT ("1"), current_arg) == 0))
            {
              properties->separate_dispatching_orb (
                            static_cast<bool> (ACE_OS::atoi(current_arg)));
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("Using separate Dispatching ORB\n")));
            }
          else
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
                          ACE_TEXT ("argument (%s).  Ignoring invalid ")
                          ACE_TEXT ("-UseSeparateDispatchingORB usage.\n"),
                          (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
            }
          if (current_arg != 0)
            arg_shifter.consume_arg ();
        }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-AllowReconnect")) == 0)
      {
        arg_shifter.consume_arg ();
        TAO_Notify_PROPERTIES::instance()->allow_reconnect (true);
      }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-DefaultConsumerAdminFilterOp")) == 0)
      {
        current_arg = arg_shifter.get_the_parameter
                      (ACE_TEXT("-DefaultConsumerAdminFilterOp"));
        CosNotifyChannelAdmin::InterFilterGroupOperator op = CosNotifyChannelAdmin::OR_OP;
        if (current_arg != 0 && (ACE_OS::strcmp(ACE_TEXT ("AND"), current_arg) == 0))
                      op = CosNotifyChannelAdmin::AND_OP;
        else if (current_arg != 0 && (ACE_OS::strcmp(ACE_TEXT ("OR"), current_arg) == 0))
                      op = CosNotifyChannelAdmin::OR_OP;
        else
          {
            ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
                        ACE_TEXT ("argument (%s).  Ignoring invalid ")
                        ACE_TEXT ("-DefaultConsumerAdminFilterOp usage.\n"),
                        (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
          }
        properties->defaultConsumerAdminFilterOp (op);
        arg_shifter.consume_arg ();
      }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-DefaultSupplierAdminFilterOp")) == 0)
      {
        current_arg = arg_shifter.get_the_parameter
                      (ACE_TEXT("-DefaultSupplierAdminFilterOp"));
        CosNotifyChannelAdmin::InterFilterGroupOperator op = CosNotifyChannelAdmin::OR_OP;
        if (current_arg != 0 && (ACE_OS::strcmp(ACE_TEXT ("AND"), current_arg) == 0))
                      op = CosNotifyChannelAdmin::AND_OP;
        else if (current_arg != 0 && (ACE_OS::strcmp(ACE_TEXT ("OR"), current_arg) == 0))
                      op = CosNotifyChannelAdmin::OR_OP;
        else
          {
            ORBSVCS_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
                        ACE_TEXT ("argument (%s).  Ignoring invalid ")
                        ACE_TEXT ("-DefaultSupplierAdminFilterOp usage.\n"),
                        (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
          }
        properties->defaultSupplierAdminFilterOp (op);
        arg_shifter.consume_arg ();
      }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ValidateClient")) == 0)
      {
        arg_shifter.consume_arg ();
        TAO_Notify_PROPERTIES::instance()->validate_client (true);
        ORBSVCS_DEBUG ((LM_DEBUG, ACE_TEXT ("Using reactive client control.\n")));
      }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ValidateClientDelay")) == 0)
      {
        current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ValidateClientDelay"));
        if (current_arg != 0)
        {
          ACE_Time_Value tv (ACE_OS::atoi (current_arg));
          TAO_Notify_PROPERTIES::instance()->validate_client_delay (tv);
        }
        else
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
            ACE_TEXT ("argument (%s).  Ignoring invalid ")
            ACE_TEXT ("-ValidateClientDelay usage.\n"),
            (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
        }
        if (current_arg != 0)
          arg_shifter.consume_arg ();
      }
      else if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT("-ValidateClientInterval")) == 0)
      {
        current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ValidateClientInterval"));
        if (current_arg != 0)
        {
          ACE_Time_Value tv (ACE_OS::atoi (current_arg));
          TAO_Notify_PROPERTIES::instance()->validate_client_interval (tv);
        }
        else
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
            ACE_TEXT ("(%P|%t) WARNING: Unrecognized ")
            ACE_TEXT ("argument (%s).  Ignoring invalid ")
            ACE_TEXT ("-ValidateClientDelay usage.\n"),
            (current_arg == 0 ? ACE_TEXT ("''") : current_arg)));
        }
        if (current_arg != 0)
          arg_shifter.consume_arg ();
      }
      else
      {
        ORBSVCS_ERROR ((LM_ERROR,
                    ACE_TEXT ("(%P|%t) Ignoring unknown option for Notify Factory: %s\n"),
                    arg_shifter.get_current()
          ));
        arg_shifter.consume_arg ();
      }
    }

  // Init the EC QoS
  {
    CosNotification::QoSProperties qos;
    this->set_threads (qos, ec_threads);
    properties->default_event_channel_qos_properties (qos);
  }

  if (!task_per_proxy)
    {
      // Set the per ConsumerAdmin QoS
      {
        if (consumer_threads > 0)
          ORBSVCS_DEBUG((LM_DEBUG, "Using %d threads for each ConsumerAdmin.\n", consumer_threads));
        CosNotification::QoSProperties qos;
        this->set_threads (qos, consumer_threads);
        properties->default_consumer_admin_qos_properties (qos);
      }

      // Set the per SupplierAdmin QoS
      {
        if (supplier_threads > 0)
          ORBSVCS_DEBUG((LM_DEBUG, "Using %d threads for each SupplierAdmin.\n", supplier_threads));
        CosNotification::QoSProperties qos;
        this->set_threads (qos, supplier_threads);
        properties->default_supplier_admin_qos_properties (qos);
      }
    }
  else
    {
      // Set the per ProxyConsumer QoS
      {
        if (supplier_threads > 0)
          ORBSVCS_DEBUG((LM_DEBUG, "Using %d threads for each Supplier.\n", supplier_threads));
        CosNotification::QoSProperties qos;
        this->set_threads (qos, supplier_threads); // lookup thread per proxy doesn't make sense.
        properties->default_proxy_consumer_qos_properties (qos);
      }

      // Set the per ProxySupplier QoS
      {
        if (consumer_threads > 0)
          ORBSVCS_DEBUG((LM_DEBUG, "Using %d threads for each Consumer.\n", consumer_threads));
        CosNotification::QoSProperties qos;
        this->set_threads (qos, consumer_threads);
        properties->default_proxy_supplier_qos_properties (qos);
      }
    }

  return 0;
}
示例#15
0
int TAO::FT_FaultNotifier_i::init (CORBA::ORB_ptr orb )
{
    int result = 0;
    this->orb_ = CORBA::ORB::_duplicate (orb);

    // Use the ROOT POA for now
    CORBA::Object_var poa_object =
        this->orb_->resolve_initial_references (TAO_OBJID_ROOTPOA);

    if (CORBA::is_nil (poa_object.in ()))
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT (" (%P|%t) Unable to initialize the POA.\n")),
                              -1);

    // Get the POA object.
    this->poa_ =
        PortableServer::POA::_narrow (poa_object.in ());


    if (CORBA::is_nil(this->poa_.in ()))
    {
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT (" (%P|%t) Unable to narrow the POA.\n")),
                              -1);
    }

    PortableServer::POAManager_var poa_manager =
        this->poa_->the_POAManager ();

    poa_manager->activate ();

    // Register with the POA.

    this->object_id_ = this->poa_->activate_object (this);

    // find my IOR

    CORBA::Object_var this_obj =
        this->poa_->id_to_reference (object_id_.in ());

    this->ior_ = this->orb_->object_to_string (this_obj.in ());


    ////////////////////////////////////////////////
    // Register with coresident Notification Channel
    CosNotifyChannelAdmin::EventChannelFactory_var notify_factory =
        TAO_Notify_EventChannelFactory_i::create (poa_.in ());
    CosNotification::QoSProperties initial_qos;
    CosNotification::AdminProperties initial_admin;
    this->notify_channel_ =
        notify_factory->create_channel (initial_qos,
                                        initial_admin,
                                        channel_id_);

    this->filter_factory_ = this->notify_channel_->default_filter_factory ();

    ///////////////////////////
    // Producer registration

    this->supplier_admin_ = this->notify_channel_->default_supplier_admin ();

    ::CosNotifyChannelAdmin::ProxyID proxyId = 0;

    //////////////////////
    // structured producer
    ::CosNotifyChannelAdmin::ProxyConsumer_var consumer
        = this->supplier_admin_->obtain_notification_push_consumer (
              ::CosNotifyChannelAdmin::STRUCTURED_EVENT,
              proxyId);

    structured_proxy_push_consumer_
        = ::CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(consumer.in ());
    if (CORBA::is_nil (this->structured_proxy_push_consumer_.in ()))
    {
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               "%T %n (%P|%t) Should not occur: Unable to narrow Structured Proxy Push Consumer\n"),
                              1);
    }

    // todo: implement a push supplier if we want to receive disconnect notice
    CosNotifyComm::StructuredPushSupplier_var stubPushSupplier =
        CosNotifyComm::StructuredPushSupplier::_nil();

    this->structured_proxy_push_consumer_->connect_structured_push_supplier (stubPushSupplier.in());

    ////////////////////
    // Sequence producer
    consumer
        = this->supplier_admin_->obtain_notification_push_consumer (
              ::CosNotifyChannelAdmin::SEQUENCE_EVENT,
              proxyId);

    this->sequence_proxy_push_consumer_
        = ::CosNotifyChannelAdmin::SequenceProxyPushConsumer::_narrow(consumer.in ());
    if (CORBA::is_nil (this->sequence_proxy_push_consumer_.in ()))
    {
        ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               "%T %n (%P|%t) Should not occur: Unable to narrow Sequence Proxy Push Consumer\n"),
                              1);
    }

    // todo: implement this if we want to receive disconnect notice
    CosNotifyComm::SequencePushSupplier_var stubSeqPushSupplier =
        CosNotifyComm::SequencePushSupplier::_nil();

    this->sequence_proxy_push_consumer_->connect_sequence_push_supplier (stubSeqPushSupplier.in());
    ///////////////////////////
    // Consumer registration

    // find the channel administrator for consumers
    this->consumer_admin_ = this->notify_channel_->default_consumer_admin ();
    if (CORBA::is_nil (this->consumer_admin_.in ()))
    {
        ORBSVCS_ERROR ((LM_ERROR,
                        "%T %n (%P|%t) NIL consumer admin\n"
                       ));
        result = -1;
    }
    // everything else happens when subscriber shows up

    ///////////////////////////////
    // Register with ReplicationManager
    if (this->rm_register_)
    {
        try
        {
            CORBA::Object_var rm_obj = orb->resolve_initial_references("ReplicationManager");
            this->replication_manager_ = ::FT::ReplicationManager::_narrow(rm_obj.in());
            if (!CORBA::is_nil (replication_manager_.in ()))
            {
                // @@: should we check to see if there's already one registered?
                FT::FaultNotifier_var notifier = FT::FaultNotifier::_narrow (this_obj.in ());
                if (! CORBA::is_nil (notifier.in ()))
                {
                    this->replication_manager_->register_fault_notifier(notifier.in ());
                    ORBSVCS_DEBUG ((LM_DEBUG,
                                    "FaultNotifier registered with ReplicationManager.\n"
                                   ));
                    this->registered_ = 1;
                }
                else
                {
                    ORBSVCS_ERROR ((LM_ERROR,
                                    "Error: Registration failed.  This is not a FaultNotifier (should not occur.)\n"
                                   ));
                }
            }
            else
            {
                ORBSVCS_ERROR ((LM_ERROR,"FaultNotifier: Can't resolve ReplicationManager, It will not be registered.\n" ));
            }
        }
        catch (const CORBA::Exception& ex)
        {
            ex._tao_print_exception (
                "FaultNotifier: Exception resolving ReplicationManager.  Notifier will not be registered.\n");
        }
    }
    else
    {
        ORBSVCS_DEBUG ((LM_DEBUG,
                        "FaultNotifier: ReplicationManager registration disabled.\n"
                       ));
    }
    ///////////////////////////////
    // Set up and ready for action
    // publish our IOR

    if(result == 0)
    {
        if (this->ior_output_file_ != 0)
        {
            this->identity_ = "file:";
            this->identity_ += ACE_TEXT_ALWAYS_CHAR(this->ior_output_file_);
            result = write_ior();
        }
    }

    if (result == 0)
    {
        if (this->ns_name_ != 0)
        {
            this->identity_ = "name:";
            this->identity_ += this->ns_name_;

            CORBA::Object_var naming_obj =
                this->orb_->resolve_initial_references ("NameService");

            if (CORBA::is_nil(naming_obj.in ())) {
                ORBSVCS_ERROR_RETURN ((LM_ERROR,
                                       "%T %n (%P|%t) Unable to find the Naming Service\n"),
                                      1);
            }

            this->naming_context_ =
                CosNaming::NamingContext::_narrow (naming_obj.in ());
            if (CORBA::is_nil(this->naming_context_.in ()))
            {
                ORBSVCS_ERROR_RETURN ((LM_ERROR,
                                       "%T %n (%P|%t) Should not occur: Can't narrow initial reference to naming context.\n"),
                                      1);
            }
            this->this_name_.length (1);
            this->this_name_[0].id = CORBA::string_dup (this->ns_name_);

            this->naming_context_->rebind (this->this_name_, this_obj.in()  //CORBA::Object::_duplicate(this_obj)
                                          );
        }
    }

    return result;
}
示例#16
0
int
TAO_IMR_Op_List::run (void)
{
  ACE_ASSERT (! CORBA::is_nil(imr_));

  ImplementationRepository::ServerInformationList_var server_list;
  ImplementationRepository::ServerInformationIterator_var server_iter;

  try
    {
      // If there is a server name, list only that server.  Otherwise, look
      // at all of them.
      if (this->server_name_.length () == 0)
        {
          this->imr_->list (this->how_many_,
            this->list_only_active_servers_,
            server_list.out(),
            server_iter.out());

          if (server_list->length() == 0)
          {
            ORBSVCS_DEBUG((LM_DEBUG, "No servers found.\n"));
            return TAO_IMR_Op::NORMAL;
          }

          for (CORBA::ULong i = 0; i < server_list->length (); i++)
            this->display_server_information (server_list[i]);

          if (!CORBA::is_nil (server_iter.in ()))
            {
              ORBSVCS_DEBUG ((LM_DEBUG, "An iterator was returned.\n"));
              for (bool done = false; !done; )
                {
                  done = server_iter->next_n (this->how_many_, server_list.out());
                  for (CORBA::ULong i = 0; i < server_list->length (); i++)
                    this->display_server_information (server_list[i]);
                }
              server_iter->destroy ();
            }
        }
      else
        {
          ImplementationRepository::ServerInformation_var si;

          this->imr_->find (this->server_name_.c_str (), si);
          if (ACE_OS::strlen (si->server.in()) > 0)
            {
              this->verbose_server_information_ = 1;
              this->display_server_information (si.in ());
            }
          else
            {
              throw ImplementationRepository::NotFound ();
            }
        }
    }
  catch (const ImplementationRepository::NotFound&)
    {
      ORBSVCS_ERROR ((LM_ERROR,
                      "Could not find server <%C>.\n",
                      this->server_name_.c_str ()));
      return TAO_IMR_Op::NOT_FOUND;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("List");
      return TAO_IMR_Op::UNKNOWN;
    }

  return TAO_IMR_Op::NORMAL;
}
示例#17
0
FT::FaultNotifier::ConsumerId TAO::FT_FaultNotifier_i::connect_structured_fault_consumer (
    CosNotifyComm::StructuredPushConsumer_ptr push_consumer,
    CosNotifyFilter::Filter_ptr filter
)
{
    METHOD_ENTRY(TAO::FT_FaultNotifier_i::connect_structured_fault_consumer);

    /////////////////////////
    // find a ProxyInfo entry
    // use the first nil entry or a new entry if no nils found

    size_t infoPos = 0;
    int looking = 1;
    for ( size_t pos = 0; looking && pos < this->proxy_infos_.size (); ++pos)
    {
        ProxyInfo & pi = this->proxy_infos_[pos];
        if (CORBA::is_nil(pi.proxyVar_.in ()))
        {
            infoPos = pos;
            looking = 0;
        }
    }
    if (looking)
    {
        infoPos = this->proxy_infos_.size();
        this->proxy_infos_.push_back(ProxyInfo());
    }

    ///////////////////////////////////////
    // Assign an ID, populate the ProxyInfo
    FT::FaultNotifier::ConsumerId result = infoPos;
    ProxyInfo & info = this->proxy_infos_[infoPos];
    info.proxyVar_
        = this->consumer_admin_->obtain_notification_push_supplier (
              ::CosNotifyChannelAdmin::STRUCTURED_EVENT,
              info.proxyId_);

    this->consumer_connects_ += 1;

    ::CosNotifyChannelAdmin::StructuredProxyPushSupplier_var proxySupplier
        = ::CosNotifyChannelAdmin::StructuredProxyPushSupplier::_narrow(info.proxyVar_.in ());

    if ( CORBA::is_nil (proxySupplier.in ()))
    {
        // this is a shoould-not-occur situation.  The consumer admin returned
        // the wrong kind of object.
        ORBSVCS_ERROR(( LM_ERROR,
                        "%T %n (%P|%t) Unexpected result: Wrong type of object returned from obtain_notification_push_supplier\n"
                      ));
    }
    else
    {
        proxySupplier->connect_structured_push_consumer ( push_consumer);

        if (! CORBA::is_nil (filter))
        {
            proxySupplier->add_filter(filter);
        }
    }

    METHOD_RETURN(TAO::FT_FaultNotifier_i::connect_structured_fault_consumer) result;
}
示例#18
0
int
TAO_IMR_Op_Register::run (void)
{
  ACE_ASSERT (! CORBA::is_nil(imr_));

  ImplementationRepository::ServerInformation_var server_information;
  ImplementationRepository::StartupOptions  local;
  ImplementationRepository::StartupOptions* options = 0;

  try
    {
      this->imr_->find (this->server_name_.c_str (),
        server_information.out ());

      if (server_name_ == server_information->server.in())
        {
          if (is_add_)
            {
              ORBSVCS_DEBUG((LM_DEBUG, "Server <%C> already registered.\n", this->server_name_.c_str ()));
              return ALREADY_REGISTERED;
            }
          options = &server_information->startup;
        }
      else // not found
        {
          if (!is_add_)
          {
            ORBSVCS_DEBUG((LM_DEBUG, "Adding Server <%C> on update command.\n", this->server_name_.c_str ()));
            is_add_ = true;
          }
          local.activation= ImplementationRepository::NORMAL;
          options = &local;
        }

      if (this->set_command_line_)
        options->command_line = CORBA::string_dup (this->command_line_.c_str ());

      if (this->set_environment_vars_)
        options->environment = this->environment_vars_;

      if (this->set_working_dir_)
        options->working_directory = CORBA::string_dup (this->working_dir_.c_str ());

      if (this->set_activation_ || is_add_)
        options->activation = this->activation_;

      if (this->set_retry_count_ || is_add_)
        options->start_limit = this->retry_count_ + 1;

      if (this->set_activator_)
        options->activator = CORBA::string_dup(this->activator_.c_str ());
      // If the command line is set, we must have an activator
      else if (this->set_command_line_ &&
              (options->activator.in () == 0 || *options->activator.in () == 0))
        {
          char host_name[MAXHOSTNAMELEN + 1];
          ACE_OS::hostname (host_name, MAXHOSTNAMELEN);
          options->activator = CORBA::string_dup (host_name);
          ORBSVCS_DEBUG ((LM_DEBUG, "Updating Server <%C> with default activator of <%s>.\n",
            this->server_name_.c_str (), options->activator.in ()));
        }

      this->imr_->add_or_update_server (this->server_name_.c_str (), *options);

      ORBSVCS_DEBUG((LM_DEBUG, "Successfully registered <%C>.\n", this->server_name_.c_str ()));
    }
  catch (const CORBA::NO_PERMISSION&)
    {
      ORBSVCS_ERROR ((LM_ERROR, "No Permission: ImplRepo is in Locked mode\n"));
      return TAO_IMR_Op::NO_PERMISSION;
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Updating server");
      return TAO_IMR_Op::UNKNOWN;
    }

  return TAO_IMR_Op::NORMAL;
}
示例#19
0
int
TAO_Naming_Server::init_new_naming (CORBA::ORB_ptr orb,
                                    PortableServer::POA_ptr poa,
                                    const ACE_TCHAR *persistence_location,
                                    void *base_addr,
                                    size_t context_size,
                                    int enable_multicast,
                                    int use_storable_context,
                                    int round_trip_timeout,
                                    int use_round_trip_timeout)
{
  try
    {
#if defined (CORBA_E_MICRO)
      ACE_UNUSED_ARG (persistence_location);
      ACE_UNUSED_ARG (base_addr);
      ACE_UNUSED_ARG (use_storable_context);
#else
      if (use_storable_context)
        {
          // In lieu of a fully implemented service configurator version
          // of this Reader and Writer, let's just take something off the
          // command line for now.
          TAO::Storable_Factory* pf = 0;
          ACE_CString directory (ACE_TEXT_ALWAYS_CHAR (persistence_location));
          ACE_NEW_RETURN (pf, TAO::Storable_FlatFileFactory (directory), -1);
          auto_ptr<TAO::Storable_Factory> persFactory(pf);

          // Use an auto_ptr to ensure that we clean up the factory in the case
          // of a failure in creating and registering the Activator.
          TAO_Storable_Naming_Context_Factory* cf =
            this->storable_naming_context_factory (context_size);
          // Make sure we got a factory
          if (cf == 0) return -1;
          auto_ptr<TAO_Storable_Naming_Context_Factory> contextFactory (cf);

          // This instance will either get deleted after recreate all or,
          // in the case of a servant activator's use, on destruction of the
          // activator.

          // Was a location specified?
          if (persistence_location == 0)
            {
              // No, assign the default location "NameService"
              persistence_location = ACE_TEXT ("NameService");
            }

          // Now make sure this directory exists
          if (ACE_OS::access (persistence_location, W_OK|X_OK))
            {
              ORBSVCS_ERROR_RETURN ((LM_ERROR, "Invalid persistence directory\n"), -1);
            }

#if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
          if (this->use_servant_activator_)
            {
              ACE_NEW_THROW_EX (this->servant_activator_,
                                TAO_Storable_Naming_Context_Activator (orb,
                                                                       persFactory.get(),
                                                                       contextFactory.get (),
                                                                       persistence_location),
                                CORBA::NO_MEMORY ());
              this->ns_poa_->set_servant_manager(this->servant_activator_);
            }
#endif /* TAO_HAS_MINIMUM_POA */
          try {  // The following might throw an exception.
            this->naming_context_ =
              TAO_Storable_Naming_Context::recreate_all (orb,
              poa,
              TAO_ROOT_NAMING_CONTEXT,
              context_size,
              0,
              contextFactory.get (),
              persFactory.get (),
              use_redundancy_);
          }
          catch (const CORBA::Exception& ex)
          {
            // The activator already took over the factories so we need to release the auto_ptr
            if (this->use_servant_activator_)
            {
              // The context factory is now owned by the activator
              // so we should release it
              contextFactory.release ();
              // If using a servant activator, the activator now owns the
              // factory, so we should release it
              persFactory.release ();
            }
            // Print out the exception and return failure
            ex._tao_print_exception (
              "TAO_Naming_Server::init_new_naming");
            return -1;
          }

        // Kind of a duplicate of the above here, but we must also release the
        // factory autoptrs in the good case as well.
        if (this->use_servant_activator_)
            {
              // The context factory is now owned by the activator
              // so we should release it
              contextFactory.release ();
              // If using a servant activator, the activator now owns the
              // factory, so we should release it
              persFactory.release ();
            }

      }
      else if (persistence_location != 0)
        //
        // Initialize Persistent Naming Service.
        //
        {

          // Create Naming Context Implementation Factory to be used for the creation of
          // naming contexts by the TAO_Persistent_Context_Index
          TAO_Persistent_Naming_Context_Factory *naming_context_factory =
            this->persistent_naming_context_factory ();
          // Make sure we got a factory.
          if (naming_context_factory == 0) return -1;

          // Allocate and initialize Persistent Context Index.
          ACE_NEW_RETURN (this->context_index_,
                          TAO_Persistent_Context_Index (orb, poa, naming_context_factory),
                          -1);

          if (this->context_index_->open (persistence_location,
                                          base_addr) == -1
              || this->context_index_->init (context_size) == -1)
            {
              if (TAO_debug_level >0)
                ORBSVCS_DEBUG ((LM_DEBUG,
                            "TAO_Naming_Server: context_index initialization failed\n"));
              return -1;
            }

          // Set the root Naming Context reference.
          this->naming_context_ =
            this->context_index_->root_context ();
        }
      else
#endif /* CORBA_E_MICRO */
        {
          //
          // Initialize Transient Naming Service.
          //
          this->naming_context_ =
            TAO_Transient_Naming_Context::make_new_context (poa,
                                                            TAO_ROOT_NAMING_CONTEXT,
                                                            context_size);

        }

#if !defined (CORBA_E_MICRO)
      // Register with the ORB's resolve_initial_references()
      // mechanism.  Primarily useful for dynamically loaded Name
      // Services.
      orb->register_initial_reference ("NameService",
                                       this->naming_context_.in ());
#endif /* CORBA_E_MICRO */

      // Set the ior of the root Naming Context.
      this->naming_service_ior_=
        orb->object_to_string (this->naming_context_.in ());

      CORBA::Object_var table_object =
        orb->resolve_initial_references ("IORTable");

      IORTable::Table_var adapter =
        IORTable::Table::_narrow (table_object.in ());
      if (CORBA::is_nil (adapter.in ()))
        {
          ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n"));
        }
      else
        {
          CORBA::String_var ior =
            orb->object_to_string (this->naming_context_.in ());
          adapter->bind ("NameService", ior.in ());
        }

#if defined (ACE_HAS_IP_MULTICAST)
      if (enable_multicast)
        {
          // @@ Marina: is there anyway to implement this stuff
          // without using ORB_Core_instance()? For example can you
          // pass the ORB as an argument?

          //
          // Install ior multicast handler.
          //
          // Get reactor instance from TAO.
          ACE_Reactor *reactor = orb->orb_core()->reactor ();

          // See if the -ORBMulticastDiscoveryEndpoint option was specified.
          ACE_CString mde (orb->orb_core ()->orb_params ()->mcast_discovery_endpoint ());

          // First, see if the user has given us a multicast port number
          // on the command-line;
          u_short port =
            orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE);

          if (port == 0)
            {
              // Check environment var. for multicast port.
              const char *port_number =
                ACE_OS::getenv ("NameServicePort");

              if (port_number != 0)
                port = static_cast<u_short> (ACE_OS::atoi (port_number));
            }

          // Port wasn't specified on the command-line or in environment -
          // use the default.
          if (port == 0)
            port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT;

          // Instantiate a handler which will handle client requests for
          // the root Naming Context ior, received on the multicast port.
          ACE_NEW_RETURN (this->ior_multicast_,
                          TAO_IOR_Multicast (),
                          -1);

          if (mde.length () != 0)
            {
              if (this->ior_multicast_->init (this->naming_service_ior_.in (),
                                              mde.c_str (),
                                              TAO_SERVICEID_NAMESERVICE) == -1)
                return -1;
            }
          else
            {
              if (this->ior_multicast_->init (this->naming_service_ior_.in (),
                                              port,
#if defined (ACE_HAS_IPV6)
                                              ACE_DEFAULT_MULTICASTV6_ADDR,
#else
                                              ACE_DEFAULT_MULTICAST_ADDR,
#endif /* ACE_HAS_IPV6 */
                                              TAO_SERVICEID_NAMESERVICE) == -1)
                return -1;
            }

          // Register event handler for the ior multicast.
          if (reactor->register_handler (this->ior_multicast_,
                                         ACE_Event_Handler::READ_MASK) == -1)
            {
              if (TAO_debug_level > 0)
                ORBSVCS_DEBUG ((LM_DEBUG,
                            "TAO_Naming_Server: cannot register Event handler\n"));
              return -1;
            }

          if (TAO_debug_level > 0)
            ORBSVCS_DEBUG ((LM_DEBUG,
                        "TAO_Naming_Server: The multicast server setup is done.\n"));
        }
#else
  ACE_UNUSED_ARG (enable_multicast);
#endif /* ACE_HAS_IP_MULTICAST */

#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
      if (use_round_trip_timeout == 1)
      {
        TimeBase::TimeT roundTripTimeoutVal = round_trip_timeout;
        CORBA::Any anyObjectVal;
        anyObjectVal <<= roundTripTimeoutVal;
        CORBA::PolicyList polList (1);
        polList.length (1);
        polList[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
                                         anyObjectVal);

        // set a timeout on the orb
        //
        CORBA::Object_var orbPolicyManagerObj =
          orb->resolve_initial_references ("ORBPolicyManager");

        CORBA::PolicyManager_var orbPolicyManager =
          CORBA::PolicyManager::_narrow (orbPolicyManagerObj.in ());
        orbPolicyManager->set_policy_overrides (polList, CORBA::SET_OVERRIDE);

        polList[0]->destroy ();
        polList[0] = CORBA::Policy::_nil ();
      }
#else
  ACE_UNUSED_ARG (use_round_trip_timeout);
  ACE_UNUSED_ARG (round_trip_timeout);
#endif /* TAO_HAS_CORBA_MESSAGING */
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "TAO_Naming_Server::init_new_naming");
      return -1;
    }

  return 0;
}
示例#20
0
int
TAO_IMR_Op_Register::parse (int argc, ACE_TCHAR **argv)
{
  // Check for enough arguments (we need at least one for the server name)
  if (argc < 2)
    {
      ORBSVCS_ERROR((LM_ERROR, "Error: Must supply at least a server name.\n"));
      this->print_usage ();
      return -1;
    }

  // Skip both the program name and the "update" command
  ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("hc:w:a:e:r:R:l:"));

  this->server_name_ = ACE_TEXT_ALWAYS_CHAR(argv[1]);
  int c;

  while ((c = get_opts ()) != -1)
    {
      switch (c)
      {
      case 'c':  // Command line arguments
        this->set_command_line_ = true;
        this->command_line_ = ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ());
        break;
      case 'e':  // set environment variables
        this->set_environment_vars_ = true;
        this->addenv( get_opts.opt_arg () );
        break;
      case 'w':  // Working Directory
        this->set_working_dir_ = true;
        this->working_dir_ = ACE_TEXT_ALWAYS_CHAR(get_opts.opt_arg ());
        break;
      case 'a':  // Activation Mode
        this->set_activation_ = true;
        if (ACE_OS::strcasecmp (get_opts.opt_arg (), ACE_TEXT("NORMAL")) == 0)
          this->activation_ = ImplementationRepository::NORMAL;
        else if (ACE_OS::strcasecmp (get_opts.opt_arg (), ACE_TEXT("MANUAL")) == 0)
          this->activation_ = ImplementationRepository::MANUAL;
        else if (ACE_OS::strcasecmp (get_opts.opt_arg (), ACE_TEXT("PER_CLIENT")) == 0)
          this->activation_ = ImplementationRepository::PER_CLIENT;
        else if (ACE_OS::strcasecmp (get_opts.opt_arg (), ACE_TEXT("AUTO_START")) == 0)
          this->activation_ = ImplementationRepository::AUTO_START;
        else
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
          "Unknown Activation Mode <%s>.\n",
          get_opts.opt_arg ()),
          -1);
        break;
      case 'r':
      case 'R':   // startup/ping Retry Count
        {
          this->set_retry_count_ = true;
          int rc = ACE_OS::atoi(get_opts.optarg);
          if (rc > 0)
            this->retry_count_ = rc;
        }
        break;
      case 'l': /// hostname of the activator
        this->activator_ = ACE_TEXT_ALWAYS_CHAR(get_opts.optarg);
        this->set_activator_ = true;
        break;
      case 'h':  // display help
        this->print_usage ();
        return -1;
      default:
        ORBSVCS_ERROR((LM_ERROR, "ERROR : Unknown option '%c'\n", (char) c));
        this->print_usage ();
        return -1;
      }
    }
  return 0;
}
示例#21
0
int
TAO_UIPMC_Connection_Handler::open (void*)
{
  TAO_MIOP_Resource_Factory *const factory =
    ACE_Dynamic_Service<TAO_MIOP_Resource_Factory>::instance (
      this->orb_core ()->configuration(),
      ACE_TEXT ("MIOP_Resource_Factory"));

  // Since only client can send data over MIOP
  // then ttl is only applicable to client socket.
  TAO_DIOP_Protocol_Properties protocol_properties;

  // Initialize values from ORB params.
  protocol_properties.send_buffer_size_ =
    factory->send_buffer_size () ?
    factory->send_buffer_size () :
    this->orb_core ()->orb_params ()->sock_sndbuf_size ();
  protocol_properties.hop_limit_ =
    this->orb_core ()->orb_params ()->ip_hoplimit ();
  protocol_properties.enable_multicast_loop_ =
    this->orb_core ()->orb_params ()->ip_multicastloop ();

  TAO_Protocols_Hooks *tph =
    this->orb_core ()->get_protocols_hooks ();

  if (tph != 0)
    {
      try
        {
          tph->client_protocol_properties_at_orb_level (protocol_properties);
        }
      catch (const ::CORBA::Exception&)
        {
          return -1;
        }
    }

  if (this->peer ().open (this->local_addr_) == -1 ||
      this->set_socket_option (this->peer (),
                               protocol_properties.send_buffer_size_,
                               0) == -1)
    {
      return -1;
    }

  if (protocol_properties.hop_limit_ >= 0)
    {
      int result = 0;
#if defined (ACE_HAS_IPV6)
      if (this->local_addr_.get_type () == AF_INET6)
        {
#if defined (ACE_WIN32)
          DWORD hop_limit =
            static_cast<DWORD> (protocol_properties.hop_limit_);
#else
          int hop_limit =
            static_cast<int> (protocol_properties.hop_limit_);
#endif
          result = this->peer ().set_option (
            IPPROTO_IPV6,
            IPV6_MULTICAST_HOPS,
            (void *) &hop_limit,
            sizeof (hop_limit));
        }
      else
#endif /* ACE_HAS_IPV6 */
        {
#if defined (ACE_WIN32)
          DWORD hop_limit =
            static_cast<DWORD> (protocol_properties.hop_limit_);
#elif defined (ACE_HAS_IP_MULTICAST_TTL_AS_INT)
          int hop_limit =
            static_cast<int> (protocol_properties.hop_limit_);
#else
          unsigned char hop_limit =
            static_cast<unsigned char> (protocol_properties.hop_limit_);
#endif
          result = this->peer ().set_option (
            IPPROTO_IP,
            IP_MULTICAST_TTL,
            (void *) &hop_limit,
            sizeof (hop_limit));
        }

      if (result != 0)
        {
          if (TAO_debug_level)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT("TAO (%P|%t) - UIPMC_Connection_Handler::open, ")
                          ACE_TEXT("couldn't set hop limit (Errno: '%m')\n")));
            }
          return -1;
        }
    }

  int result = 0;
#if defined (ACE_HAS_IPV6)
  if (this->local_addr_.get_type () == AF_INET6)
    {
#if defined (ACE_WIN32)
      DWORD enable_loop =
        static_cast<DWORD> (protocol_properties.enable_multicast_loop_);
#elif defined (ACE_HAS_IPV6_MULTICAST_LOOP_AS_BOOL)
      bool enable_loop =
          static_cast<bool> (protocol_properties.enable_multicast_loop_);
#else
      unsigned int enable_loop =
        static_cast<unsigned int> (protocol_properties.enable_multicast_loop_);
#endif
      result = this->peer ().set_option (
        IPPROTO_IPV6,
        IPV6_MULTICAST_LOOP,
        (void *) &enable_loop,
        sizeof (enable_loop));
    }
  else
#endif /* ACE_HAS_IPV6 */
    {
#if defined (ACE_WIN32)
      DWORD enable_loop =
        static_cast<DWORD> (protocol_properties.enable_multicast_loop_);
#elif defined (ACE_HAS_IP_MULTICAST_LOOP_AS_INT)
      int enable_loop =
        static_cast<int> (protocol_properties.enable_multicast_loop_);
#else
      unsigned char enable_loop =
        static_cast<unsigned char> (protocol_properties.enable_multicast_loop_);
#endif
      result = this->peer ().set_option (
        IPPROTO_IP,
        IP_MULTICAST_LOOP,
        (void *) &enable_loop,
        sizeof (enable_loop));
    }

  if (result != 0)
    {
      if (TAO_debug_level)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) - UIPMC_Connection_Handler::open, ")
                      ACE_TEXT ("couldn't %s multicast packets looping (Errno: '%m')\n"),
                      protocol_properties.enable_multicast_loop_ ?
                      ACE_TEXT ("enable") : ACE_TEXT ("disable")
                     ));
        }
      return -1;
    }

  this->send_hi_water_mark_ = factory->send_hi_water_mark ();
  if (!this->send_hi_water_mark_)
    {
#if defined (ACE_LACKS_SO_SNDBUF)
      // Assume a small buffer
      this->send_hi_water_mark_ = 1024u;
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_ERROR,
                    ACE_TEXT ("TAO (%P|%t) - UIPMC_Connection_Handler::")
                    ACE_TEXT ("open, -ORBSendHighWaterMark not specified ")
                    ACE_TEXT ("using %u bytes\n"),
                    this->send_hi_water_mark_));
#else
      int size = sizeof (this->send_hi_water_mark_);
      result =
        this->peer ().get_option (SOL_SOCKET,
                                  SO_SNDBUF,
                                  static_cast<void *> (&this->send_hi_water_mark_),
                                  &size);
      if (!result)
        {
          // Note unix kernals double the value that is set (to hold the
          // internal data structures seporating each packet) and this doubled
          // value is what is returned by the get_option, so it is best to halve.
          this->send_hi_water_mark_ >>= 1;

          // Also Note that some kernals return stupid values (such as solaris
          // when using the loopback interface) so cater for rediculously small
          // values.
          if (this->send_hi_water_mark_ < 256u)
            {
              this->send_hi_water_mark_ = 256u;
              if (TAO_debug_level)
                ORBSVCS_ERROR ((LM_ERROR,
                            ACE_TEXT ("TAO (%P|%t) - UIPMC_Connection_Handler::")
                            ACE_TEXT ("open, -ORBSendHighWaterMark not specified, ")
                            ACE_TEXT ("using value of %u bytes\n"),
                            this->send_hi_water_mark_));
            }
          else if (TAO_debug_level)
            ORBSVCS_ERROR ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - UIPMC_Connection_Handler::")
                        ACE_TEXT ("open, -ORBSendHighWaterMark not specified, ")
                        ACE_TEXT ("using -ORBSndSock value of %u bytes\n"),
                        this->send_hi_water_mark_));
        }
示例#22
0
TAO_BEGIN_VERSIONED_NAMESPACE_DECL

void
TAO::Security::ORBInitializer::pre_init (
    PortableInterceptor::ORBInitInfo_ptr info)
{
  // Narrow to a TAO_ORBInitInfo object to get access to the
  // allocate_tss_slot_id() TAO extension.
  TAO_ORBInitInfo_var tao_info =
    TAO_ORBInitInfo::_narrow (info);

  if (CORBA::is_nil (tao_info.in ()))
    {
      if (TAO_debug_level > 0)
        ORBSVCS_ERROR ((LM_ERROR,
                    "(%P|%t) Security_ORBInitializer::pre_init:\n"
                    "(%P|%t)    Unable to narrow "
                    "\"PortableInterceptor::ORBInitInfo_ptr\" to\n"
                    "(%P|%t)   \"TAO_ORBInitInfo_ptr.\"\n"));

      throw CORBA::INTERNAL ();
    }

  // Reserve a TSS slot in the ORB core internal TSS resources for the
  // thread-specific portion of Security::Current.
  size_t tss_slot = tao_info->allocate_tss_slot_id (0 /* no cleanup function */);

#if 1

#if 0 // why am I getting a BAD_OPERATION from no SSL context?!
  CORBA::String_var orb_id = info->orb_id ();

  // Create the SecurityLevel2::Current object.
  SecurityLevel2::Current_ptr current = SecurityLevel2::Current::_nil ();
  ACE_NEW_THROW_EX (current,
                    TAO_Security_Current (tss_slot, orb_id.in ()),
                    CORBA::NO_MEMORY (
                                      CORBA::SystemException::_tao_minor_code (
                         TAO::VMCID,
                         ENOMEM),
                       CORBA::COMPLETED_NO));

  SecurityLevel2::Current_var security_current = current;

  // Register the SecurityLevel2::Current object reference with the
  // ORB.
  info->register_initial_reference ("SecurityCurrent",
                                    security_current.in ());
#endif
  /*
   * Instantiate and register the SecurityLevel2::SecurityManager
   */
  SecurityLevel2::SecurityManager_ptr manager2;
  ACE_NEW_THROW_EX (manager2,
                    TAO::Security::SecurityManager (/*need args*/),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  SecurityLevel2::SecurityManager_var security_manager2 = manager2;

  // Register the SecurityLevel2::SecurityManager object reference
  // with the ORB.
  info->register_initial_reference ("SecurityLevel2:SecurityManager",
                                    security_manager2.in ());

#endif

  // Rather than reserve another TSS slot in the ORB core internal TSS
  // resources for the thread-specific portion of
  // SecurityLevel3::SecurityCurrent object, we will re-use the slot
  // allocated earlier.

  // Create the SecurityLevel3::Current object.
  SecurityLevel3::SecurityCurrent_ptr current3;
  ACE_NEW_THROW_EX (current3,
                    TAO::SL3::SecurityCurrent (tss_slot,
                                               tao_info->orb_core ()),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  SecurityLevel3::SecurityCurrent_var security_current3 = current3;

  // Register the SecurityLevel2::Current object reference with the
  // ORB.
  info->register_initial_reference ("SecurityLevel3:SecurityCurrent",
                                    security_current3.in ());

  // Create the SecurityLevel3::CredentialsCurator object.
  SecurityLevel3::CredentialsCurator_ptr curator;
  ACE_NEW_THROW_EX (curator,
                    TAO::SL3::CredentialsCurator,
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  SecurityLevel3::CredentialsCurator_var credentials_curator = curator;

  // Register the SecurityLevel3::CredentialsCurator object reference
  // with the ORB.
  info->register_initial_reference ("SecurityLevel3:CredentialsCurator",
                                    credentials_curator.in ());

  // Create the SecurityLevel3::SecurityManager object.
  SecurityLevel3::SecurityManager_ptr manager3;
  ACE_NEW_THROW_EX (manager3,
                    TAO::SL3::SecurityManager (credentials_curator.in ()),
                    CORBA::NO_MEMORY (
                      CORBA::SystemException::_tao_minor_code (
                        TAO::VMCID,
                        ENOMEM),
                      CORBA::COMPLETED_NO));

  SecurityLevel3::SecurityManager_var security_manager3 = manager3;

  // Register the SecurityLevel3::SecurityManager object reference
  // with the ORB.
  info->register_initial_reference ("SecurityLevel3:SecurityManager",
                                    security_manager3.in ());
}
示例#23
0
void
TAO_ECG_CDR_Message_Sender::send_message  (const TAO_OutputCDR &cdr,
                                           const ACE_INET_Addr &addr)
{
  if (this->endpoint_rptr_.get () == 0)
    {
      ORBSVCS_ERROR ((LM_ERROR, "Attempt to invoke send_message() "
                            "on non-initialized sender object.\n"));
      throw CORBA::INTERNAL ();
    }

  CORBA::ULong max_fragment_payload = this->mtu () -
    TAO_ECG_CDR_Message_Sender::ECG_HEADER_SIZE;
  // ACE_ASSERT (max_fragment_payload != 0);

#if defined (ACE_HAS_BROKEN_DGRAM_SENDV)
  const int TAO_WRITEV_MAX = ACE_IOV_MAX - 1;
#else
  const int TAO_WRITEV_MAX = ACE_IOV_MAX;
#endif /* ACE_HAS_BROKEN_DGRAM_SENDV */
  iovec iov[TAO_WRITEV_MAX];

  CORBA::ULong total_length;
  CORBA::ULong fragment_count =
    this->compute_fragment_count (cdr.begin (),
                                  cdr.end (),
                                  TAO_WRITEV_MAX,
                                  max_fragment_payload,
                                  total_length);

  CORBA::ULong request_id = this->endpoint_rptr_->next_request_id ();

  // Reserve the first iovec for the header...
  int iovcnt = 1;
  CORBA::ULong fragment_id = 0;
  CORBA::ULong fragment_offset = 0;
  CORBA::ULong fragment_size = 0;
  for (const ACE_Message_Block* b = cdr.begin ();
       b != cdr.end ();
       b = b->cont ())
    {
      CORBA::ULong l = b->length ();

      char* rd_ptr = b->rd_ptr ();

      iov[iovcnt].iov_base = rd_ptr;
      iov[iovcnt].iov_len  = l;
      fragment_size += l;
      ++iovcnt;
      while (fragment_size > max_fragment_payload)
        {
          // This fragment is full, we have to send it...

          // First adjust the last iov entry:
          CORBA::ULong last_mb_length =
            max_fragment_payload - (fragment_size - l);
          iov[iovcnt - 1].iov_len = last_mb_length;

          this->send_fragment (addr,
                               request_id,
                               total_length,
                               max_fragment_payload,
                               fragment_offset,
                               fragment_id,
                               fragment_count,
                               iov,
                               iovcnt);
          ++fragment_id;
          fragment_offset += max_fragment_payload;

          // Reset, but don't forget that the last Message_Block
              // may need to be sent in multiple fragments..
          l -= last_mb_length;
          rd_ptr += last_mb_length;
          iov[1].iov_base = rd_ptr;
          iov[1].iov_len = l;
          fragment_size = l;
          iovcnt = 2;
        }
      if (fragment_size == max_fragment_payload)
        {
          // We filled a fragment, but this time it was filled
          // exactly, the treatment is a little different from the
          // loop above...
          this->send_fragment (addr,
                               request_id,
                               total_length,
                               max_fragment_payload,
                               fragment_offset,
                               fragment_id,
                               fragment_count,
                               iov,
                               iovcnt);
          ++fragment_id;
          fragment_offset += max_fragment_payload;

          iovcnt = 1;
          fragment_size = 0;
        }
      if (iovcnt == TAO_WRITEV_MAX)
        {
          // Now we ran out of space in the iovec, we must send a
          // fragment to work around that....
          this->send_fragment (addr,
                               request_id,
                               total_length,
                               fragment_size,
                               fragment_offset,
                               fragment_id,
                               fragment_count,
                               iov,
                               iovcnt);
          ++fragment_id;
          fragment_offset += fragment_size;

          iovcnt = 1;
          fragment_size = 0;
        }
    }
  // There is something left in the iovvec that we must send
  // also...
  if (iovcnt != 1)
    {
      // Now we ran out of space in the iovec, we must send a
      // fragment to work around that....
      this->send_fragment (addr,
                           request_id,
                           total_length,
                           fragment_size,
                           fragment_offset,
                           fragment_id,
                           fragment_count,
                           iov,
                           iovcnt);
      ++fragment_id;
      fragment_offset += fragment_size;

      // reset, not needed here...
      // iovcnt = 1;
      // fragment_size = 0;
    }
  // ACE_ASSERT (total_length == fragment_offset);
  // ACE_ASSERT (fragment_id == fragment_count);

}
示例#24
0
TAO_END_VERSIONED_NAMESPACE_DECL

//#define PG_PS_UNIT_TEST
#ifdef PG_PS_UNIT_TEST
#include "orbsvcs/PortableGroup/PG_Properties_Encoder.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

int TAO_PG::test_encode_decode ()
{
  int result = 1;
  static const long testLong = 123456L;
  static const char * testLongKey = "MyLong";

  static const char * testString = "Now is the time for all good people.";
  static const char * testStringKey = "plover";

  static const double testDouble = 3.1415;
  static const char * testDoubleKey = "pi";

  PortableGroup::Properties_var property_set = new PortableGroup::Properties;
  //scope encoder to be sure its gone before decoding
  {
    TAO_PG::Encoder encoder;
    PortableGroup::Value value;
    value <<= (CORBA::Long) testLong;
    encoder.add (testLongKey, value);

    value <<= testString;
    encoder.add (testStringKey, value);

    value <<= (CORBA::Double) testDouble;
    encoder.add (testDoubleKey, value);

    encoder.encode (property_set);
  }

  TAO::PG_Property_Set decoder (property_set);

  CORBA::Long longResult = 0;
  if (find (decoder, testLongKey, longResult) )
  {
    if (longResult != testLong)
    {
      ORBSVCS_ERROR ( (LM_ERROR,
        "%n\n%T: %s = %d expecting %d\n",
          testLongKey,
          (int)longResult,
          (int)testLong
        ));
      result = 0;
    }
  }
  else
  {
    ORBSVCS_ERROR ( (LM_ERROR,
      "%n\n%T: Can't find value for %s\n", testLongKey
      ));
    result = 0;
  }

  const char * stringResult = "";
  if (find (decoder, testStringKey, stringResult))
  {
    if (0 != ACE_OS::strcmp (testString, stringResult))
    {
      ORBSVCS_ERROR ( (LM_ERROR,
        "%n\n%T: %s = \"%s\" expecting \"%s\"\n",
          testStringKey,
          (int)stringResult,
          (int)testString
        ));
      result = 0;
    }
  }
  else
  {
    ORBSVCS_ERROR ( (LM_ERROR,
      "%n\n%T: Can't find value for %s\n", testStringKey
      ));
    result = 0;
  }


  CORBA::Double doubleResult = 0.0;
  if (find (decoder, testDoubleKey, doubleResult))
  {
    if (doubleResult != testDouble)
    {
      ORBSVCS_ERROR ( (LM_ERROR,
        "%n\n%T: %s = \"%f\" expecting \"%f\"\n",
          testDoubleKey,
          doubleResult,
          testDouble
        ));
      result = 0;
    }
  }
  else
  {
    ORBSVCS_ERROR ( (LM_ERROR,
      "%n\n%T: Can't find value for %s\n", testDoubleKey
      ));
    result = 0;
  }

  return result;
}
示例#25
0
int
TAO::PG_Object_Group::set_primary_member (
    TAO_IOP::TAO_IOR_Property * prop,
    const PortableGroup::Location & the_location)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    guard,
                    this->internals_,
                    0);
  int result = 1;
  MemberInfo * info = 0;
  if (this->members_.find (the_location, info) == 0)
    {
      int cleared = 0;
      this->primary_location_ = the_location;
      for (MemberMap_Iterator it = this->members_.begin ();
           !cleared && it != this->members_.end ();
           ++it)
        {
          cleared = (*it).int_id_->is_primary_;
          (*it).int_id_->is_primary_ = 0;
        }
      info->is_primary_ = 1;

      int set_ok =
        this->manipulator_.set_primary (prop,
                                        this->reference_.in (),
                                        info->member_.in ());
      if (!set_ok)
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT ("%T %n (%P|%t) - ")
                          ACE_TEXT ("Can't set primary in IOGR .\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }

      if (result && this->increment_version ())
        {
          this->distribute_iogr ();
        }
      else
        {
          if (TAO_debug_level > 3)
            {
              ORBSVCS_DEBUG ((LM_DEBUG,
                          ACE_TEXT("TAO-PG (%P|%t) - set_primary_location ")
                          ACE_TEXT("throwing PrimaryNotSet because increment")
                          ACE_TEXT("version failed.\n")
                          ));
            }
//@@: ACE_THROW (FT::PrimaryNotSet());
          result = 0;
        }
    }
  else
    {
      if (TAO_debug_level > 3)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO-PG (%P|%t) - set_primary_location ")
                      ACE_TEXT ("throwing MemberNotFound.\n")));
        }
      throw PortableGroup::MemberNotFound();
    }

  return result;
}
示例#26
0
int
TAO::SSLIOP::Protocol_Factory::init (int argc, ACE_TCHAR* argv[])
{
  char *certificate_path = 0;
  char *private_key_path = 0;
  char *dhparams_path = 0;
  char *ca_file = 0;
  CORBA::String_var ca_dir;
  ACE_TCHAR *rand_path = 0;

  int certificate_type = -1;
  int private_key_type = -1;
  int dhparams_type = -1;

  int prevdebug = -1;

  CSIIOP::AssociationOptions csiv2_target_supports =
    CSIIOP::Integrity | CSIIOP::Confidentiality;
  CSIIOP::AssociationOptions csiv2_target_requires =
    CSIIOP::Integrity | CSIIOP::Confidentiality;

  // Force the Singleton instance to be initialized/instantiated.
  // Some SSLIOP option combinations below will result in the
  // Singleton instance never being initialized.  In that case,
  // problems may occur later on due to lack of initialization of the
  // underlying SSL library (e.g. OpenSSL), which occurs when an
  // ACE_SSL_Context is instantiated.

  // This directive processing initializes ACE_SSL_Context as well
  // as registers ACE_SSL for correct cleanup.
  ACE_Service_Config::process_directive (
    ACE_STATIC_SERVICE_DIRECTIVE ("ACE_SSL_Initializer", ""));

  // The code is cleaner this way anyway.
  ACE_SSL_Context * ssl_ctx = ACE_SSL_Context::instance ();

  size_t session_id_len =
    (sizeof session_id_context_ >= SSL_MAX_SSL_SESSION_ID_LENGTH)
      ? SSL_MAX_SSL_SESSION_ID_LENGTH
      : sizeof session_id_context_;

  // Note that this function returns 1, if the operation succeded.
  // See SSL_CTX_set_session_id_context(3)
  if( 1 != ::SSL_CTX_set_session_id_context (ssl_ctx->context(),
                                             session_id_context_,
                                             session_id_len))
  {
    if (TAO_debug_level > 0)
      ORBSVCS_ERROR ((LM_ERROR,
                  ACE_TEXT ("TAO (%P|%t) Unable to set the session id ")
                  ACE_TEXT ("context to \'%C\'\n"), session_id_context_));

    return -1;
  }

  for (int curarg = 0; curarg != argc; ++curarg)
    {
      if ((ACE_OS::strcasecmp (argv[curarg],
                               ACE_TEXT("-verbose")) == 0)
          || (ACE_OS::strcasecmp (argv[curarg],
                                  ACE_TEXT("-v")) == 0))
        {
          if (TAO_debug_level == 0)
            {
              prevdebug = TAO_debug_level;
              TAO_debug_level = 1;
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLNoProtection")) == 0)
        {
          // Enable the eNULL cipher.  Note that enabling the "eNULL"
          // cipher only disables encryption.  However, certificate
          // exchanges will still occur.
          if (::SSL_CTX_set_cipher_list (ssl_ctx->context (),
                                         "ALL:eNULL") == 0)
            {
              ORBSVCS_DEBUG ((LM_ERROR,
                          ACE_TEXT ("TAO (%P|%t) Unable to set eNULL ")
                          ACE_TEXT ("SSL cipher in SSLIOP ")
                          ACE_TEXT ("factory.\n")));

              return -1;
            }

          // This does not disable secure invocations on the server
          // side.  It merely enables insecure ones.  On the client
          // side, secure invocations will be disabled unless
          // overridden by a SecurityLevel2::QOPPolicy in the object
          // reference.
          this->qop_ = ::Security::SecQOPNoProtection;

          ACE_SET_BITS (csiv2_target_supports,
                        CSIIOP::NoProtection);

          ACE_CLR_BITS (csiv2_target_requires,
                        CSIIOP::Confidentiality);
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLCertificate")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              certificate_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &certificate_path);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLPrivateKey")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              private_key_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &private_key_path);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLAuthenticate")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              int mode = SSL_VERIFY_NONE;
              if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("NONE")) == 0)
                {
                  mode = SSL_VERIFY_NONE;
                }
              else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("SERVER")) == 0)
                {
                  mode = SSL_VERIFY_PEER;

                  ACE_SET_BITS (csiv2_target_supports,
                                CSIIOP::EstablishTrustInTarget
                                | CSIIOP::EstablishTrustInClient);
                }
              else if (ACE_OS::strcasecmp (argv[curarg], ACE_TEXT("CLIENT")) == 0
                       || ACE_OS::strcasecmp (argv[curarg],
                                              ACE_TEXT("SERVER_AND_CLIENT")) == 0)
                {
                  mode = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT;

                  ACE_SET_BITS (csiv2_target_supports,
                                CSIIOP::EstablishTrustInTarget
                                | CSIIOP::EstablishTrustInClient);

                  ACE_SET_BITS (csiv2_target_requires,
                                CSIIOP::EstablishTrustInClient);
                }

              ssl_ctx->default_verify_mode (mode);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLAcceptTimeout")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              float timeout = 0;

              if (sscanf (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), "%f", &timeout) != 1
                  || timeout < 0)
                ORBSVCS_ERROR_RETURN ((LM_ERROR,
                                   "ERROR: Invalid -SSLAcceptTimeout "
                                   "value: %s.\n",
                                   argv[curarg]),
                                  -1);
              else
                this->timeout_.set (timeout);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLDHparams")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              dhparams_type = parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &dhparams_path);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLCAfile")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              (void) parse_x509_file (ACE_TEXT_ALWAYS_CHAR(argv[curarg]), &ca_file);
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLCApath")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              ca_dir = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(argv[curarg]));
            }
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLrand")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              rand_path = argv[curarg];
            }
        }

#if !defined (__Lynx__)
      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLServerCipherOrder")) == 0)
        {
          ::SSL_CTX_set_options (ssl_ctx->context (),
                                 SSL_OP_CIPHER_SERVER_PREFERENCE);
        }

      else if (ACE_OS::strcasecmp (argv[curarg],
                                   ACE_TEXT("-SSLCipherList")) == 0)
        {
          curarg++;
          if (curarg < argc)
            {
              if (::SSL_CTX_set_cipher_list (ssl_ctx->context (),
                                             ACE_TEXT_ALWAYS_CHAR(argv[curarg])) == 0)
                {
                  ORBSVCS_DEBUG ((LM_ERROR,
                              ACE_TEXT ("TAO (%P|%t) Unable to set cipher ")
                              ACE_TEXT ("list in SSLIOP ")
                              ACE_TEXT ("factory.\n")));

                  return -1;
                }
            }
        }
#endif

    }

  // Load some (more) entropy from the user specified sources
  // in addition to what's pointed to by ACE_SSL_RAND_FILE_ENV
  if (rand_path != 0)
  {
    short errors = 0;
    ACE_TCHAR *file_name = 0;
    const ACE_TCHAR *path = ACE_OS::strtok_r (rand_path,
                                              TAO_PATH_SEPARATOR_STRING,
                                              &file_name);
    while ( path != 0)
    {
      if( -1 == ssl_ctx->seed_file (ACE_TEXT_ALWAYS_CHAR(path), -1))
      {
        ++errors;
        ORBSVCS_ERROR ((LM_ERROR,
                    ACE_TEXT ("TAO (%P|%t) Failed to load ")
                    ACE_TEXT ("more entropy from <%s>: %m\n"), path));
      }
      else
      {
        if (TAO_debug_level > 0)
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) Loaded ")
                      ACE_TEXT ("more entropy from <%s>\n"), path));
      }

      path = ACE_OS::strtok_r (0, TAO_PATH_SEPARATOR_STRING, &file_name);
    }

    if (errors > 0)
      return -1;
  }

  // Load any trusted certificates explicitely rather than relying on
  // previously set SSL_CERT_FILE and/or SSL_CERT_PATH environment variable
  if (ca_file != 0 || ca_dir.in () != 0)
    {
      if (ssl_ctx->load_trusted_ca (ca_file, ca_dir.in ()) != 0)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) Unable to load ")
                      ACE_TEXT ("CA certs from %C%C%C\n"),
                      ((ca_file != 0) ? ca_file : "a file pointed to by "
                                                  ACE_SSL_CERT_FILE_ENV
                                                  " env var (if any)"),
                      ACE_TEXT (" and "),
                      ((ca_dir.in () != 0) ?
                          ca_dir.in () : "a directory pointed to by "
                                         ACE_SSL_CERT_DIR_ENV
                                         " env var (if any)")));

          return -1;
        }
      else
        {
          if (TAO_debug_level > 0)
            ORBSVCS_DEBUG ((LM_INFO,
                        ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ")
                        ACE_TEXT ("Trusted Certificates from %C%C%C\n"),
                        ((ca_file != 0) ? ca_file : "a file pointed to by "
                                                    ACE_SSL_CERT_FILE_ENV
                                                    " env var (if any)"),
                        ACE_TEXT (" and "),
                        ((ca_dir.in () != 0) ?
                            ca_dir.in () : "a directory pointed to by "
                                           ACE_SSL_CERT_DIR_ENV
                                           " env var (if any)")));
        }
    }

  // Load in the DH params.  If there was a file explicitly specified,
  // then we do that here, otherwise we load them in from the cert file.
  // Note that we only do this on the server side, I think so we might
  // need to defer this 'til later in the acceptor or something...
  if (dhparams_path == 0)
    {
      // If the user didn't explicitly specify a DH parameters file, we
      // also might find it concatenated in the certificate file.
      // So, we set the dhparams to that if it wasn't explicitly set.
      dhparams_path = certificate_path;
      dhparams_type = certificate_type;
    }

  if (dhparams_path != 0)
    {
      if (ssl_ctx->dh_params (dhparams_path,
                              dhparams_type) != 0)
        {
          if (dhparams_path != certificate_path)
            {
              // We only want to fail catastrophically if the user specified
              // a dh parameter file and we were unable to actually find it
              // and load from it.
              ORBSVCS_ERROR ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) SSLIOP_Factory: ")
                          ACE_TEXT ("unable to set ")
                          ACE_TEXT ("DH parameters <%C>\n"),
                          dhparams_path));
              return -1;
            }
          else
            {
              if (TAO_debug_level > 0)
                ORBSVCS_DEBUG ((LM_INFO,
                            ACE_TEXT ("(%P|%t) SSLIOP_Factory: ")
                            ACE_TEXT ("No DH parameters found in ")
                            ACE_TEXT ("certificate <%C>; either none ")
                            ACE_TEXT ("are needed (RSA) or problems ")
                            ACE_TEXT ("will ensue later.\n"),
                            dhparams_path));
            }
        }
      else
        {
          if (TAO_debug_level > 0)
            ORBSVCS_DEBUG ((LM_INFO,
                        ACE_TEXT ("(%P|%t) SSLIOP loaded ")
                        ACE_TEXT ("Diffie-Hellman params ")
                        ACE_TEXT ("from %C\n"),
                        dhparams_path));
        }
    }

  // The certificate must be set before the private key since the
  // ACE_SSL_Context attempts to check the private key for
  // consistency.  That check requires the certificate to be available
  // in the underlying SSL_CTX.
  if (certificate_path != 0)
    {
      if (ssl_ctx->certificate (certificate_path,
                                certificate_type) != 0)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) Unable to set ")
                      ACE_TEXT ("SSL certificate <%C> ")
                      ACE_TEXT ("in SSLIOP factory.\n"),
                      certificate_path));

          return -1;
        }
      else
        {
          if (TAO_debug_level > 0)
            ORBSVCS_DEBUG ((LM_INFO,
                        ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ")
                        ACE_TEXT ("SSL certificate ")
                        ACE_TEXT ("from %C\n"),
                        certificate_path));
        }
    }

  if (private_key_path != 0)
    {
      if (ssl_ctx->private_key (private_key_path, private_key_type) != 0)
        {

          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) Unable to set ")
                      ACE_TEXT ("SSL private key ")
                      ACE_TEXT ("<%C> in SSLIOP factory.\n"),
                      private_key_path));

          return -1;
        }
      else
        {
          if (TAO_debug_level > 0)
            ORBSVCS_DEBUG ((LM_INFO,
                        ACE_TEXT ("TAO (%P|%t) SSLIOP loaded ")
                        ACE_TEXT ("Private Key ")
                        ACE_TEXT ("from <%C>\n"),
                        private_key_path));
        }
    }

  if (this->register_orb_initializer (csiv2_target_supports,
                                      csiv2_target_requires) != 0)
    return -1;

  if (prevdebug != -1)
    TAO_debug_level = prevdebug;

  return 0;
}
示例#27
0
void
TAO::PG_Object_Group::create_members (size_t count)
{
  // assume internals is locked
  // @@ what if factories were passed as criteria?

  CORBA::String_var factory_type;
  PortableGroup::FactoryInfos_var factories =
  this->factory_registry_->list_factories_by_role (
        role_.c_str(),
        factory_type.out ());

  CORBA::ULong factory_count = factories->length ();
  if (factory_count > 0)
    {
      CORBA::ULong factory_pos = 0;
      while (members_.current_size () < count && factory_pos < factory_count)
        {
          const PortableGroup::FactoryInfo & factory_info =
            (*factories)[factory_pos];
          const PortableGroup::Location & factory_location =
            factory_info.the_location;
          if (0 != this->members_.find (factory_location))
            {
              ///////////////////////////////////////////
              // If a factory refuses to create a replica
              // it's not fatal.
              try
                {
                  PortableGroup::GenericFactory::FactoryCreationId_var fcid;
                  CORBA::Object_var member =
                    factory_info.the_factory->create_object (
                      this->type_id_.in (),
                      factory_info.the_criteria,
                      fcid. out());

                  // convert the new member to a stringified IOR to avoid
                  // contamination with group info
                  CORBA::String_var member_ior_string =
                    orb_->object_to_string (member.in ());

                  PortableGroup::ObjectGroup_var new_reference =
                    this->add_member_to_iogr (member.in ());

                  // Convert new member back to a (non group) ior.
                  CORBA::Object_var member_ior =
                    this->orb_->string_to_object (member_ior_string.in ());

                  MemberInfo * info = 0;
                  ACE_NEW_THROW_EX (info, MemberInfo(
                                                     member_ior.in(),
                                                     factory_location,
                                                     factory_info.the_factory,
                                                     fcid.in ()),
                                    CORBA::NO_MEMORY());

                  if (this->members_.bind (factory_location, info) != 0)
                    {
                      throw CORBA::NO_MEMORY();
                    }
                  this->reference_ =
                    new_reference; // note var-to-var assignment does
                                   // a duplicate
                }
              catch (const CORBA::Exception&)
                {
                  // log, but otherwise ignore the errorf
                  if (TAO_debug_level > 0)
                    {
                      ORBSVCS_ERROR ((LM_ERROR,
                                  ACE_TEXT ("PG (%P|%t) Replica Factory ")
                                  ACE_TEXT ("@ %s refused create_object ")
                                  ACE_TEXT ("request for type %s\n"),
                                  static_cast<const char *> (factory_info.the_location[0].id),
                                  static_cast<const char *> (this->type_id_.in ())
                                  ));
                    }
                }
            }
        }

      if (this->increment_version ())
        {
          this->distribute_iogr ();
        }
    }
  else
    {
      throw PortableGroup::NoFactory();
    }
}
示例#28
0
int
TAO_Notify_Service_Driver::init (int argc, ACE_TCHAR *argv[])
{
  // Check if -ORBDaemon is specified and if so, daemonize at this moment,
  // -ORBDaemon in the ORB core is faulty, see bugzilla 3335
  TAO_Daemon_Utility::check_for_daemon (argc, argv);

  if (this->parse_args(argc, argv) != 0)
    return -1;

  // initalize the ORB.
  if (this->init_ORB (argc, argv) != 0)
    return -1;

  this->notify_service_ = TAO_Notify_Service::load_default ();

  if (this->notify_service_ == 0)
    {
      if (TAO_debug_level > 0)
        {
          ORBSVCS_ERROR ((LM_ERROR,
                      ACE_TEXT ("Service not found. Check service ")
                      ACE_TEXT ("configurator file.\n")));
        }
      return -1;
    }

  if (this->separate_dispatching_orb_)
    {
      if (this->init_dispatching_ORB (argc, argv) != 0)
        {
          return -1;
        }

      this->notify_service_->init_service2 (this->orb_.in (), this->dispatching_orb_.in());
    }
  else
    {
      this->notify_service_->init_service (this->orb_.in ());
    }

  this->logging_worker_.start();

  if (this->nthreads_ > 0) // we have chosen to run in a thread pool.
    {
      if (TAO_debug_level > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      ACE_TEXT("Running %d ORB threads\n"),
                      this->nthreads_));
        }
      worker_.orb (this->orb_.in ());

      // Task activation flags.
      long const flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        this->orb_->orb_core ()->orb_params ()->thread_creation_flags ();

      int const priority =
        ACE_Sched_Params::priority_min (ACE_Utils::truncate_cast<ACE_Sched_Params::Policy> (this->orb_->orb_core ()->orb_params ()->sched_policy ()),
                                        ACE_Utils::truncate_cast<int> (this->orb_->orb_core ()->orb_params ()->scope_policy ()));

      if (worker_.activate (flags,
                            this->nthreads_, 0, priority) != 0)
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "Cannot activate client threads\n"), -1);
        }
    }

  // Check first if the naming service
  if (this->use_name_svc_)
    {
      // Resolve the naming service.
      int const ns_ret = this->resolve_naming_service ();

      if (ns_ret != 0)
        return -1;
    }

  if (TAO_debug_level > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT("\nStarting up the Notification Service...\n")));
    }

  // Activate the factory
  this->notify_factory_ =
    notify_service_->create (this->poa_.in (),
                             this->notify_factory_name_.c_str ());

  ACE_ASSERT (!CORBA::is_nil (this->notify_factory_.in ()));

  if (this->bootstrap_) // Enable corbaloc usage
    {
      CORBA::Object_var table_object =
        this->orb_->resolve_initial_references ("IORTable");

      IORTable::Table_var adapter =
        IORTable::Table::_narrow (table_object.in ());

      if (CORBA::is_nil (adapter.in ()))
        {
          if (TAO_debug_level > 0)
            {
              ORBSVCS_ERROR ((LM_ERROR,
                          "Nil IORTable. corbaloc support not enabled.\n"));
            }
        }
      else
        {
          CORBA::String_var ior =
            this->orb_->object_to_string (this->notify_factory_.in ());
          adapter->bind (this->notify_factory_name_.c_str (), ior.in ());
        }
    }

  // Register with the Name service, if asked
  if (this->use_name_svc_ && !CORBA::is_nil (this->naming_.in ()))
    {
      CosNaming::Name_var name =
        this->naming_->to_name (this->notify_factory_name_.c_str ());

      this->naming_->rebind (name.in (),
                             this->notify_factory_.in ());

      if (TAO_debug_level > 0)
        {
          ORBSVCS_DEBUG ((LM_DEBUG,
                      "Registered with the naming service as: %C\n",
                      this->notify_factory_name_.c_str()));
        }

      if (this->register_event_channel_)
        {
          // If we don't have any name configured, default to the standard name
          if (this->notify_channel_name_.is_empty ())
            {
              notify_channel_name_.insert (NOTIFY_CHANNEL_NAME);
            }

          for (ACE_Unbounded_Set<ACE_CString>::const_iterator ci (
                this->notify_channel_name_); !ci.done(); ci++)
            {
              // create an event channel
              CosNotifyChannelAdmin::ChannelID id;

              CosNotification::QoSProperties initial_qos;
              CosNotification::AdminProperties initial_admin;

              CosNotifyChannelAdmin::EventChannel_var ec;
              TAO_Notify_EventChannelFactory* factory_impl =
                dynamic_cast<TAO_Notify_EventChannelFactory*> (
                  this->notify_factory_->_servant ());
              if (factory_impl == 0)
                {
                  ec = this->notify_factory_->create_channel (initial_qos,
                                                              initial_admin,
                                                              id);
                }
              else
                {
                  ec = factory_impl->create_named_channel (
                                       initial_qos, initial_admin,id,
                                       (*ci).c_str ());
                }

              name = this->naming_->to_name ((*ci).c_str ());

              this->naming_->rebind (name.in (), ec.in ());

              if (TAO_debug_level > 0)
                {
                  ORBSVCS_DEBUG ((LM_DEBUG,
                              "Registered an Event Channel with the naming "
                              "service as: %C\n",
                              (*ci).c_str()));
                }
            }
        }
    }

  // Write IOR to a file, if asked.
  // Note: do this last to ensure that we're up and running before the file is written
  CORBA::String_var str =
    this->orb_->object_to_string (this->notify_factory_.in ());

  if (this->ior_output_file_name_)
    {
       FILE* ior_output_file = ACE_OS::fopen (ior_output_file_name_,
                                              ACE_TEXT("w"));
       if (ior_output_file == 0)
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "Unable to open %s for writing: %p\n",
                             this->ior_output_file_name_, "Notify_Service"),
                             -1);
        }

      ACE_OS::fprintf (ior_output_file, "%s", str.in ());
      ACE_OS::fclose (ior_output_file);
    }
  else if (TAO_debug_level > 0)
    {
      ORBSVCS_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("The Notification Event Channel Factory IOR is <%C>\n"),
                  str.in ()));
    }

  return 0;
}
示例#29
0
文件: AV_Core.cpp 项目: asdlei00/ACE
int
TAO_AV_Core::load_default_flow_protocol_factories (void)
{
  const char *udp_flow = "UDP_Flow_Factory";
  const char *tcp_flow = "TCP_Flow_Factory";
  const char *rtp_flow = "RTP_Flow_Factory";
  const char *rtcp_flow = "RTCP_Flow_Factory";
  const char *sfp_flow = "SFP_Flow_Factory";

  TAO_AV_Flow_Protocol_Factory *udp_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *udp_item = 0;

  udp_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_flow);
  if (udp_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "UDP Flow Factory"));

      ACE_NEW_RETURN (udp_flow_factory,
                      TAO_AV_UDP_Flow_Factory,
                      -1);
    }
  else udp_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (udp_item, TAO_AV_Flow_Protocol_Item ("UDP_Flow_Factory"), -1);
  udp_item->factory (udp_flow_factory);

  this->flow_protocol_factories_.insert (udp_item);

#if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)

  const char *udp_qos_flow = "UDP_QoS_Flow_Factory";
  TAO_AV_Flow_Protocol_Factory *udp_qos_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *udp_qos_flow_item = 0;

  udp_qos_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (udp_qos_flow);
  if (udp_qos_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "UDP QoS Flow Factory"));

      ACE_NEW_RETURN (udp_qos_flow_factory,
                      TAO_AV_UDP_QoS_Flow_Factory,
                      -1);
    }
  else udp_qos_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (udp_qos_flow_item, TAO_AV_Flow_Protocol_Item ("UDP_QoS_Flow_Factory"), -1);
  udp_qos_flow_item->factory (udp_qos_flow_factory);

  this->flow_protocol_factories_.insert (udp_qos_flow_item);

#endif /* defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS) */

#if defined ACE_HAS_SCTP

  const char *sctp_seq_flow = "SCTP_SEQ_Flow_Factory";
  TAO_AV_Flow_Protocol_Factory *sctp_seq_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *sctp_seq_flow_item = 0;

  sctp_seq_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sctp_seq_flow);
  if (sctp_seq_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "SCTP SEQ Flow Factory"));

      ACE_NEW_RETURN (sctp_seq_flow_factory,
                      TAO_AV_SCTP_SEQ_Flow_Factory,
                      -1);
    }
  else sctp_seq_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (sctp_seq_flow_item, TAO_AV_Flow_Protocol_Item ("SCTP_SEQ_Flow_Factory"), -1);
  sctp_seq_flow_item->factory (sctp_seq_flow_factory);

  this->flow_protocol_factories_.insert (sctp_seq_flow_item);

#endif /* ACE_HAS_SCTP */

  TAO_AV_Flow_Protocol_Factory *tcp_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *tcp_item = 0;

  tcp_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (tcp_flow);
  if (tcp_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "TCP Flow Factory"));

      ACE_NEW_RETURN (tcp_flow_factory,
                      TAO_AV_TCP_Flow_Factory,
                      -1);
    }
  else tcp_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (tcp_item, TAO_AV_Flow_Protocol_Item ("TCP_Flow_Factory"), -1);
  tcp_item->factory (tcp_flow_factory);

  this->flow_protocol_factories_.insert (tcp_item);

  TAO_AV_Flow_Protocol_Factory *rtp_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *rtp_item = 0;

  rtp_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtp_flow);
  if (rtp_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "RTP Flow Factory"));

      ACE_NEW_RETURN (rtp_flow_factory,
                      TAO_AV_RTP_Flow_Factory,
                      -1);
    }
  else rtp_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (rtp_item, TAO_AV_Flow_Protocol_Item ("RTP_Flow_Factory"), -1);
  rtp_item->factory (rtp_flow_factory);

  this->flow_protocol_factories_.insert (rtp_item);

  TAO_AV_Flow_Protocol_Factory *rtcp_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *rtcp_item = 0;

  rtcp_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (rtcp_flow);
  if (rtcp_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "RTCP Flow Factory"));

      ACE_NEW_RETURN (rtcp_flow_factory,
                      TAO_AV_RTCP_Flow_Factory,
                      -1);
    }
  else rtcp_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (rtcp_item, TAO_AV_Flow_Protocol_Item ("RTCP_Flow_Factory"), -1);
  rtcp_item->factory (rtcp_flow_factory);

  this->flow_protocol_factories_.insert (rtcp_item);

  TAO_AV_Flow_Protocol_Factory *sfp_flow_factory = 0;
  TAO_AV_Flow_Protocol_Item *sfp_item = 0;

  sfp_flow_factory =
    ACE_Dynamic_Service<TAO_AV_Flow_Protocol_Factory>::instance (sfp_flow);
  if (sfp_flow_factory == 0)
    {
      if (TAO_debug_level)
        ORBSVCS_ERROR ((LM_WARNING,
                    "(%P|%t) WARNING - No %s found in Service Repository."
                    "  Using default instance.\n",
                    "SFP Flow Factory"));

      ACE_NEW_RETURN (sfp_flow_factory,
                      TAO_AV_SFP_Factory,
                      -1);
    }
  else sfp_flow_factory->ref_count = 1;

  ACE_NEW_RETURN (sfp_item, TAO_AV_Flow_Protocol_Item ("SFP_Flow_Factory"), -1);
  sfp_item->factory (sfp_flow_factory);

  this->flow_protocol_factories_.insert (sfp_item);

  return 0;
}
示例#30
0
int
TAO_MonitorManager::ORBTask::svc (void)
{
  try
    {
      if (CORBA::is_nil (this->orb_.in ()))
        {
          ORBSVCS_ERROR_RETURN ((LM_ERROR,
                             "(%P|%t) TAO_MonitorManager: Unable to "
                             "initialize the ORB\n"),
                            1);
        }

      PortableServer::POA_var poa;

      {
        ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->mutex_, -1);

        CORBA::Object_var obj =
          this->orb_->resolve_initial_references ("RootPOA");

        poa = PortableServer::POA::_narrow (obj.in ());

        if (CORBA::is_nil (poa.in ()))
          {
            ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               "(%P|%t) TAO_MonitorManager: Unable to "
                               "resolve the RootPOA\n"),
                              1);
          }

        PortableServer::POAManager_var poa_manager = poa->the_POAManager ();
        poa_manager->activate ();

        // Activate the object
        NotificationServiceMonitor_i* servant;
        ACE_NEW_RETURN (servant,
                        NotificationServiceMonitor_i (this->orb_.in ()), 1);
        PortableServer::ServantBase_var owner_transfer(servant);
        PortableServer::ObjectId_var id = poa->activate_object (servant);

        // Register the object with the IORTable
        obj = poa->id_to_reference (id.in ());
        CosNotification::NotificationServiceMonitorControl_var monitor =
          CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ());
        CORBA::String_var ior = this->orb_->object_to_string (monitor.in ());
        obj = this->orb_->resolve_initial_references ("IORTable");
        IORTable::Table_var iortable = IORTable::Table::_narrow (obj.in ());

        if (CORBA::is_nil (iortable.in ()))
          {
            ORBSVCS_ERROR_RETURN ((LM_ERROR,
                               "(%P|%t) TAO_MonitorManager: Unable to "
                               "resolve the IORTable\n"),
                              1);
          }

        iortable->bind(ACE_TEXT_ALWAYS_CHAR(mc_orb_name_.c_str()), ior.in ());

        if (this->use_name_svc_)
          {
            TAO_Naming_Client nc;
            nc.init (this->orb_.in ());
            CosNaming::Name name (1);
            name.length (1);
            name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(mc_orb_name_.c_str()));
            nc->rebind (name, monitor.in ());
          }

        if (this->ior_output_.length () > 0)
          {
            FILE* fp = ACE_OS::fopen (this->ior_output_.c_str (), "w");

            if (fp == 0)
              {
                ORBSVCS_ERROR_RETURN ((LM_ERROR,
                                   ACE_TEXT ("(%P|%t) TAO_MonitorManager: "
                                   ACE_TEXT ("Unable to write to %s\n")),
                                   this->ior_output_.c_str ()),
                                  1);
              }
            else
              {
                ACE_OS::fprintf (fp, "%s", ior.in ());
                ACE_OS::fclose (fp);
              }
          }
      }

      // R1: race condition (partially fixed):
      // TAO_MonitorManager::fini() is called directly after
      // TAO_MonitorManager::run(), the shutdown call on the ORB could
      // happen but the ORB::run() loop won't exit.
      startup_barrier_.wait ();
      this->orb_->run ();

      ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->mutex_, -1);

      // Destroy the POA and ORB
      if (!CORBA::is_nil (poa.in ()))
        {
          poa->destroy (true, true);
        }

      this->orb_->destroy ();

      // Set to nil to avoid double shutdown in TAO_MonitorManager::fini()
      this->orb_ = CORBA::ORB::_nil ();
    }
  catch (const CORBA::Exception& ex)
    {
      if (!CORBA::is_nil (this->orb_.in ()))
        {
          try
            {
              this->orb_->shutdown ();
            }
          catch (...)
            {
            }

          this->orb_ = CORBA::ORB::_nil ();
        }

      ex._tao_print_exception ("Caught in "
                               "TAO_MonitorManager::ORBTask::svc");
    }
  catch (...)
    {
      if (!CORBA::is_nil (this->orb_.in ()))
        {
          try
            {
              this->orb_->shutdown ();
            }
          catch (...)
            {
            }
          this->orb_ = CORBA::ORB::_nil ();
        }

      ORBSVCS_ERROR ((LM_ERROR,
                  "Unexpected exception type caught "
                  "in TAO_MonitorManager::ORBTask::svc"));
    }

  return 0;
}