Exemplo n.º 1
0
  // Operations for CCMObject interface.
  void
  Connector_Servant_Impl_Base::remove (void)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::remove (void)");

    try
    {
      Container_var cnt_safe = Container::_duplicate(this->container_.in ());
      PortableServer::POA_var port_poa = cnt_safe->the_port_POA ();

      {
        ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                            mon,
                            this->lock_,
                            CORBA::NO_RESOURCES ());
        // Removing Facets
        for (FacetTable::const_iterator iter =
              this->facet_table_.begin ();
            iter != this->facet_table_.end ();
            ++iter)
          {
            PortableServer::ObjectId_var facet_id =
              port_poa->reference_to_id (iter->second);

            port_poa->deactivate_object (facet_id);
          }
      }

      this->ccm_remove ();

      PortableServer::ObjectId_var oid;
      cnt_safe->uninstall_servant (this,
                                  Container_Types::COMPONENT_t,
                                  oid.out ());

      if (this->home_servant_)
        {
          this->home_servant_->update_component_map (oid);
          this->home_servant_->_remove_ref ();
          this->home_servant_ = 0;
        }
    }
    catch (const CORBA::Exception& ex)
    {
      // log error and propagate so error gets reported to deployment framework
      CIAO_ERROR (1, (LM_ERROR, CLINFO "Connector_Servant_Impl_Base::remove - CORBA exception : %C\n", ex._info ().c_str ()));
      ex._raise (); // propagate
    }
  }
Exemplo n.º 2
0
  void
  Receiver_exec_i::add_shape_to_list (const char* topic, const char* color, CORBA::UShort size,
                                      CORBA::UShort pos_x, CORBA::UShort pos_y)
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->mutex_, CORBA::INTERNAL ());

    CORBA::ULong seq_length = this->shape_info_seq_.length();
    this->shape_info_seq_.length(seq_length + 1);
    this->shape_info_seq_[seq_length].shape = CORBA::string_dup (topic);
    this->shape_info_seq_[seq_length].color = CORBA::string_dup (color);
    this->shape_info_seq_[seq_length].size = size;
    this->shape_info_seq_[seq_length].posX = pos_x;
    this->shape_info_seq_[seq_length].posY = pos_y;
  }
Exemplo n.º 3
0
template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::resume_connection (void)
{
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ());

    if (this->is_connected () == 0)
      throw CosNotifyChannelAdmin::NotConnected ();

    if (this->consumer()->is_suspended () == 0)
      throw CosNotifyChannelAdmin::ConnectionAlreadyActive ();
  }

  this->consumer()->resume ();
}
Exemplo n.º 4
0
template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::subscription_change (const CosNotification::EventTypeSeq & added,
                                                           const CosNotification::EventTypeSeq & removed)
{
  TAO_Notify_EventTypeSeq seq_added (added);
  TAO_Notify_EventTypeSeq seq_removed (removed);

  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                        CORBA::INTERNAL ());

    this->subscribed_types_.add_and_remove (seq_added, seq_removed);
  }

  this->event_manager().subscription_change (this, seq_added, seq_removed);
}
Exemplo n.º 5
0
  void
  UCCTestComponent_exec_i::write_fixed (void)
  {
    ::UCCFixedSizeStruct_Test::UCCFixedSizedStructTestConnector::Writer_var fixed_writer
      = this->ciao_context_->get_connection_fixed_size_write_data ();

    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->fixed_mutex_, CORBA::INTERNAL ());
    {
      for (CORBA::UShort i = 1; i < NR_OF_KEYS + 1; ++i)
        {
          ACE_DEBUG ((LM_DEBUG, "Write fixed %i\n", i));
          fixed_writer->write_one (*(this->fixed_samples_[i]), ::DDS::HANDLE_NIL);
        }
    }
  }
Exemplo n.º 6
0
  void
  UCCTestComponent_exec_i::write_variable (void)
  {
    ::UCCVariableSizedStruct_Test::UCCVariableSizedStructTestConnector::Writer_var var_writer
      = this->ciao_context_->get_connection_var_size_write_data ();

    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->var_mutex_, CORBA::INTERNAL ());
    {
      for (CORBA::UShort i = 1; i < NR_OF_KEYS + 1; ++i)
        {
          ACE_DEBUG ((LM_DEBUG, "Write variable %C\n", this->var_samples_[i]->symbol.in ()));
          var_writer->write_one (*(this->var_samples_[i]), ::DDS::HANDLE_NIL);
        }
    }
  }
CORBA::Boolean
TAO_CEC_ProxyPushSupplier::consumer_non_existent (
      CORBA::Boolean_out disconnected)
{
  CORBA::Object_var consumer;
  {
    ACE_GUARD_THROW_EX (
        ACE_Lock, ace_mon, *this->lock_,
        CORBA::INTERNAL ());

    disconnected = 0;
    if (this->is_connected_i () == 0)
      {
        disconnected = 1;
        return 0;
      }

#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
    if (this->is_typed_ec () )
      {
        if (CORBA::is_nil (this->nopolicy_typed_consumer_.in ()))
          {
            return 0;
          }
        consumer = CORBA::Object::_duplicate
          (this->nopolicy_typed_consumer_.in ());
      }
    else
      {
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
    if (CORBA::is_nil (this->nopolicy_consumer_.in ()))
      {
        return 0;
      }
    consumer = CORBA::Object::_duplicate (this->nopolicy_consumer_.in ());
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
      } /* ! this->is_typed_ec */
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
  }

#if (TAO_HAS_MINIMUM_CORBA == 0)
  return consumer->_non_existent ();
#else
  return 0;
#endif /* TAO_HAS_MINIMUM_CORBA */
}
Exemplo n.º 8
0
  void
  UCCTestComponent_exec_i::create_fixed_sized_samples (void)
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->fixed_mutex_, CORBA::INTERNAL ());
    ACE_DEBUG ((LM_DEBUG, "Component_exec_i::create_fixed_sized_samples - "
                          "Create fixed sized samples.\n"));
    for (::CORBA::UShort i = 1; i < NR_OF_KEYS + 1; ++i)
      {
        UCCFixedSizedStructTest_i* new_key = new UCCFixedSizedStructTest_i;
        new_key->x = i;
        new_key->y = new_key->x;
        new_key->z = 2*i;

        this->fixed_samples_[i] = new_key;
      }
  }
Exemplo n.º 9
0
void
TAO_Notify_ProxySupplier::connect (TAO_Notify_Consumer *consumer)
{
  // Adopt the consumer
  TAO_Notify_Consumer::Ptr auto_consumer (consumer);

  TAO_Notify_Atomic_Property_Long& consumer_count = this->admin_properties().consumers ();
  const TAO_Notify_Property_Long& max_consumers = this->admin_properties().max_consumers ();

  if (max_consumers != 0 && consumer_count >= max_consumers.value ())
  {
    throw CORBA::IMP_LIMIT (); // we've reached the limit of consumers connected.
  }

  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                        CORBA::INTERNAL ());

    // if consumer is set and reconnect not allowed we get out.
    if (this->is_connected () && TAO_Notify_PROPERTIES::instance()->allow_reconnect() == false)
      {
          throw CosEventChannelAdmin::AlreadyConnected ();
      }

    // Adopt the consumer
    if (this->consumer_.get() != 0)
      auto_consumer->assume_pending_events (*this->consumer_.get ());
    this->consumer_ = auto_consumer;

    this->consumer_admin_->subscribed_types (this->subscribed_types_); // get the parents subscribed types.
  }

  // Inform QoS values.
  ACE_ASSERT (this->consumer_.get() != 0);
  this->consumer_->qos_changed (this->qos_properties_);

  TAO_Notify_EventTypeSeq removed;

  this->event_manager().subscription_change (this, this->subscribed_types_, removed);

  this->event_manager().connect (this);

  // Increment the global consumer count
  ++consumer_count;
}
Exemplo n.º 10
0
 void
 UCCTestComponent_exec_i::create_variable_sized_samples (void)
 {
   ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                       this->var_mutex_, CORBA::INTERNAL ());
   ACE_DEBUG ((LM_DEBUG, "Component_exec_i::create_variable_sized_samples - "
                     "Create variable sized samples\n"));
   for (::CORBA::UShort i = 1; i < NR_OF_KEYS + 1; ++i)
     {
       UCCVariableSizedStructTest_i* new_key = new UCCVariableSizedStructTest_i;
       char key[7];
       ACE_OS::sprintf (key, "KEY_%d", i);
       new_key->symbol = CORBA::string_dup (key);
       new_key->x = i;
       new_key->y = new_key->x;
       this->var_samples_[i] = new_key;
     }
 }
Exemplo n.º 11
0
  void
  Sender_exec_i::ccm_activate (void)
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->mutex_, CORBA::INTERNAL ());

    for (CORBA::UShort i = 1; i < this->keys_ + 1; ++i)
      {
        char key[7];
        UnkeyedTest *new_key = new UnkeyedTest;
        ACE_OS::sprintf (key, "KEY_%d", i);
        new_key->key = CORBA::string_dup(key);
        new_key->iteration = 0;

        this->ktests_[key] = new_key;
      }
     this->last_key = this->ktests_.begin ();
  }
Exemplo n.º 12
0
void
TAO_EC_ProxyPushSupplier::push (const RtecEventComm::EventSet& event,
                                TAO_EC_QOS_Info& qos_info)
{
  // The mutex is already held by the caller (usually the filter()
  // method)
  if (!this->is_connected_i ())
    return; // TAO_THROW (RtecEventComm::Disconnected ());????

  if (this->suspended_)
    return;

  TAO_ESF_RefCount_Guard<CORBA::ULong> ace_mon (this->refcount_);
  // The guard will decrement the reference count, notice that the
  // reference count can become 0, but this is not the right spot to
  // check for that and destroy the object.
  // If we did so then we would destroy the object, and consequently
  // the mutex, but the mutex is used later when the stack unwinds and
  // the filter() method tries to destroy the mutex (that originally
  // acquired the mutex in the first place).
  // So the correct thing to do is to just decrement the reference
  // count and let the filter() method do the destruction.

  RtecEventComm::PushConsumer_var consumer =
    RtecEventComm::PushConsumer::_duplicate (this->consumer_.in ());

  this->pre_dispatch_hook (const_cast<RtecEventComm::EventSet&> (event));

  {
    // We have to release the lock to avoid dead-locks.
    TAO_EC_Unlock reverse_lock (*this->lock_);

    ACE_GUARD_THROW_EX (TAO_EC_Unlock, ace_mon, reverse_lock,
                        RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    this->event_channel_->dispatching ()->push (this,
                                                consumer.in (),
                                                event,
                                                qos_info);
  }

  if (this->child_ != 0)
    this->child_->clear ();
}
Exemplo n.º 13
0
CosNotifyFilter::FilterID
TAO_Notify_FilterAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter)
{
  if (CORBA::is_nil (new_filter))
    throw CORBA::BAD_PARAM ();

  ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                      CORBA::INTERNAL ());

  CosNotifyFilter::FilterID new_id = this->filter_ids_.id ();

  CosNotifyFilter::Filter_var new_filter_var =
    CosNotifyFilter::Filter::_duplicate (new_filter);

  if (this->filter_list_.bind (new_id, new_filter_var) == -1)
      throw CORBA::INTERNAL ();
  else
    return new_id;
}
Exemplo n.º 14
0
void
TAO_Notify_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added,
                                        const CosNotification::EventTypeSeq & removed)

{
  TAO_Notify_EventTypeSeq seq_added (added);
  TAO_Notify_EventTypeSeq seq_removed (removed);

  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                        CORBA::INTERNAL ());

    this->subscribed_types_.add_and_remove (seq_added, seq_removed);

    TAO_Notify_Subscription_Change_Worker worker (added, removed);

    this->proxy_container().collection ()->for_each (&worker);
  }
}
Exemplo n.º 15
0
template<class PROXY, class C, class I,ACE_SYNCH_DECL> void
TAO_ESF_Delayed_Changes<PROXY,C,I,ACE_SYNCH_USE>::shutdown (void)
{
  ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_,
      CORBA::INTERNAL ());

  if (this->busy_count_ == 0)
    {
      // We can shutdown the object immediately
      this->shutdown_i ();
    }
  else
    {
      ACE_Command_Base* command;
      ACE_NEW (command,
               Shutdown_Command (this));
      this->command_queue_.enqueue_tail (command);
      this->write_delay_count_++;
    }
}
Exemplo n.º 16
0
void
TAO_EC_Default_ProxyPushSupplier::disconnect_push_supplier ()
{
  RtecEventComm::PushConsumer_var consumer;
  int connected = 0;

  {
    ACE_GUARD_THROW_EX (
        ACE_Lock, ace_mon, *this->lock_,
        CORBA::INTERNAL ());
    // @@ RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    connected = this->is_connected_i ();
    consumer = this->consumer_._retn ();

    if (connected)
      this->cleanup_i ();
  }

  // Notify the event channel....
  this->event_channel_->disconnected (this);

  if (!connected)
    {
      return;
    }

  if (this->event_channel_->disconnect_callbacks ())
    {
      try
        {
          consumer->disconnect_push_consumer ();
        }
      catch (const CORBA::Exception& ex)
        {
          // Ignore exceptions, we must isolate other clients from
          // problems on this one.
          ex._tao_print_exception ("ProxySupplier::disconnect_push_supplier");
        }
    }
}
Exemplo n.º 17
0
int
TAO_EC_ProxyPushSupplier::filter_nocopy (RtecEventComm::EventSet& event,
                                         TAO_EC_QOS_Info& qos_info)
{
  Destroy_Guard auto_destroy (this->refcount_,
                              this->event_channel_,
                              this);

  int result = 0;
  {
    ACE_GUARD_THROW_EX (
            ACE_Lock, ace_mon, *this->lock_,
            RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    if (this->is_connected_i ())
      {
        result = this->child_->filter_nocopy (event, qos_info);
      }
  }
  return result;
}
Exemplo n.º 18
0
void
TAO_Notify_ProxySupplier::init (TAO_Notify_ConsumerAdmin* consumer_admin)
{
  ACE_ASSERT (consumer_admin != 0 && this->consumer_admin_.get() == 0);

  TAO_Notify_Proxy::initialize (consumer_admin);

  this->consumer_admin_.reset (consumer_admin);

  this->filter_admin_.event_channel (
    this->consumer_admin_->event_channel());

  const CosNotification::QoSProperties &default_ps_qos =
    TAO_Notify_PROPERTIES::instance ()->default_proxy_supplier_qos_properties ();

  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                          CORBA::INTERNAL ());
    this->TAO_Notify_Object::set_qos (default_ps_qos);
  }
}
Exemplo n.º 19
0
  /// Protected operations.
  void
  Connector_Servant_Impl_Base::add_facet (
    const char *port_name,
    ::CORBA::Object_ptr port_ref)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::add_facet");

    if (0 == port_name || ::CORBA::is_nil (port_ref))
      {
        throw ::CORBA::BAD_PARAM ();
      }

    {
      ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                          mon,
                          this->lock_,
                          CORBA::NO_RESOURCES ());

      this->facet_table_[port_name] = ::CORBA::Object::_duplicate (port_ref);
    }
  }
Exemplo n.º 20
0
  void
  Sender_exec_i::get_started (void)
  {
    this->ready_to_start_ = true;
    this->start ();

    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, _guard,
                        this->mutex_, CORBA::INTERNAL ());

    for (CORBA::UShort i = 1; i < this->keys_ + 1; ++i)
      {
        char key[7];
        KeyedTest *new_key = new KeyedTest;
        ACE_OS::sprintf (key, "KEY_%d", i);
        new_key->key = CORBA::string_dup(key);
        new_key->iteration = 0;

        this->ktests_[key] = new_key;
      }
     this->last_key_ = this->ktests_.begin ();
}
void
TAO_CEC_ProxyPushSupplier::push_to_consumer (const CORBA::Any& event)
{
  CosEventComm::PushConsumer_var consumer;
  {
    ACE_GUARD_THROW_EX (
            ACE_Lock, ace_mon, *this->lock_,
            CORBA::INTERNAL ());
    // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    if (this->is_connected_i () == 0)
      return; // ACE_THROW (CosEventComm::Disconnected ());????

    consumer =
      CosEventComm::PushConsumer::_duplicate (this->consumer_.in ());
  }

  TAO_CEC_ConsumerControl *control =
               this->event_channel_->consumer_control ();
  try
    {
      consumer->push (event);

      // Inform the control that we were able to push something
      control->successful_transmission(this);
    }
  catch (const CORBA::OBJECT_NOT_EXIST&)
    {
      control->consumer_not_exist (this);
    }
  catch (CORBA::SystemException& sysex)
    {
      control->system_exception (this,
                                 sysex);
    }
  catch (const CORBA::Exception&)
    {
      // Shouldn't happen, but does not hurt
    }
}
Exemplo n.º 22
0
RTCORBA::Mutex_ptr
TAO_Named_RT_Mutex_Manager::open_named_mutex (const char *name)
{
#if (TAO_HAS_NAMED_RT_MUTEXES == 1)
  // The following should be atomic.
  ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                      monitor,
                      this->lock_,
                      CORBA::INTERNAL ());

  // If we find the mutex, simply return it.
  RTCORBA::Mutex_var mutex;
  if (this->map_.find (name, mutex) != 0)
    throw RTCORBA::RTORB::MutexNotFound ();

  // Return the one we found.
  return mutex._retn ();
#else /* TAO_HAS_NAMED_RT_MUTEXES */
  ACE_UNUSED_ARG (name);
  throw ::CORBA::NO_IMPLEMENT ();
#endif /* TAO_HAS_NAMED_RT_MUTEXES */
}
Exemplo n.º 23
0
template<class PROXY, class C, class I,ACE_SYNCH_DECL> void
TAO_ESF_Delayed_Changes<PROXY,C,I,ACE_SYNCH_USE>::
    disconnected (PROXY *proxy)
{
  ACE_GUARD_THROW_EX (ACE_SYNCH_MUTEX_T, ace_mon, this->busy_lock_,
      CORBA::INTERNAL ());

  if (this->busy_count_ == 0)
    {
      // We can remove the object immediately
      this->disconnected_i (proxy);
    }
  else
    {
      ACE_Command_Base* command;
      ACE_NEW (command,
               Disconnected_Command (this,
                                     proxy));
      this->command_queue_.enqueue_tail (command);
      this->write_delay_count_++;
    }
}
Exemplo n.º 24
0
void
TAO_CEC_ProxyPullSupplier::disconnect_pull_supplier ()
{
  CosEventComm::PullConsumer_var consumer;

  {
    ACE_GUARD_THROW_EX (
        ACE_Lock, ace_mon, *this->lock_,
        CORBA::INTERNAL ());
    // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    if (this->is_connected_i () == 0)
      throw CORBA::BAD_INV_ORDER ();

    consumer = this->consumer_._retn ();

    this->cleanup_i ();
  }

  // Notify the event channel....
  this->event_channel_->disconnected (this);

  if (CORBA::is_nil (consumer.in ()))
    return;

  if (this->event_channel_->disconnect_callbacks ())
    {
      try
        {
          consumer->disconnect_pull_consumer ();
        }
      catch (const CORBA::Exception& ex)
        {
          // Ignore exceptions, we must isolate other clients from
          // problems on this one.
          ex._tao_print_exception ("ProxySupplier::disconnect_pull_supplier");
        }
    }
}
Exemplo n.º 25
0
::Components::ConsumerDescription *
Servant_Impl_Base::lookup_consumer_description (
    const char *port_name)
{
    CIAO_TRACE("Servant_Impl_Base::lookup_consumer_description");

    if (0 == port_name)
    {
        /// Calling function will throw InvalidName after getting this.
        return 0;
    }

    ::Components::ConsumerDescription_var cd;
    ConsumerTable::const_iterator iter;

    {
        ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                            mon,
                            this->lock_,
                            CORBA::NO_RESOURCES ());

        iter = this->consumer_table_.find (port_name);

        if (iter != this->consumer_table_.end ())
        {
            ::Components::ConsumerDescription *cdp = 0;
            ACE_NEW_THROW_EX (cdp,
                              ::OBV_Components::ConsumerDescription,
                              CORBA::NO_MEMORY ());

            cdp->name (iter->first.c_str ());
            cdp->type_id (iter->second->_interface_repository_id ());
            cdp->consumer (iter->second);
            cd = cdp;
        }
    }

    return cd._retn ();
}
Exemplo n.º 26
0
void
TAO_CEC_ProxyPushConsumer::disconnect_push_consumer ()
{
  CosEventComm::PushSupplier_var supplier;

  {
    ACE_GUARD_THROW_EX (
        ACE_Lock, ace_mon, *this->lock_,
        CORBA::INTERNAL ());
    // @@ CosEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    if (!this->is_connected_i ())
      throw CORBA::BAD_INV_ORDER (); // @@ add user exception?

    supplier = this->supplier_._retn ();

    this->cleanup_i ();
  }

  // Notify the event channel...
  this->event_channel_->disconnected (this);

  if (CORBA::is_nil (supplier.in ()))
    return;

  if (this->event_channel_->disconnect_callbacks ())
    {
      try
        {
          supplier->disconnect_push_supplier ();
        }
      catch (const CORBA::Exception&)
        {
          // Ignore exceptions, we must isolate other clients from
          // failures on this one.
        }
    }
}
Exemplo n.º 27
0
void
TAO_EC_ProxyPushConsumer::shutdown (void)
{
  RtecEventComm::PushSupplier_var supplier;

  {
    ACE_GUARD_THROW_EX (
        ACE_Lock, ace_mon, *this->lock_,
        RtecEventChannelAdmin::EventChannel::SYNCHRONIZATION_ERROR ());

    supplier = this->supplier_._retn ();
    this->connected_ = false;

    this->shutdown_hook ();

    if (this->filter_ != 0)
      {
        this->filter_->shutdown ();

        this->cleanup_i ();
      }
  }

  this->deactivate ();

  if (CORBA::is_nil (supplier.in ()))
    return;

  try
    {
      supplier->disconnect_push_supplier ();
    }
  catch (const CORBA::Exception&)
    {
      // Ignore exceptions, we must isolate other clients from
      // failures on this one.
    }
}
Exemplo n.º 28
0
  CORBA::Object_ptr
  Connector_Servant_Impl_Base::lookup_facet (const char *port_name)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::lookup_facet");
    if (!port_name)
      {
        return CORBA::Object::_nil ();
      }

    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                        mon,
                        this->lock_,
                        CORBA::NO_RESOURCES ());

    FacetTable::const_iterator iter = this->facet_table_.find (port_name);

    if (iter == this->facet_table_.end ())
      {
        return CORBA::Object::_nil ();
      }

    return CORBA::Object::_duplicate (iter->second);
  }
Exemplo n.º 29
0
void
TAO_Named_RT_Mutex_Manager::destroy_mutex (RTCORBA::Mutex_ptr mutex)
{
  TAO_RT_Mutex *tao_mutex =
    dynamic_cast<TAO_RT_Mutex *> (mutex);

  // If this mutex is named, then we need to remove it from our table.
  // Otherwise, we don't have to do anything.
  const char *name = tao_mutex->name ();
  if (name != 0)
    {
      // The following should be atomic.
      ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                          monitor,
                          this->lock_,
                          CORBA::INTERNAL ());

      int result =
        this->map_.unbind (name);

      if (result != 0)
        throw ::CORBA::INTERNAL ();
    }
}
Exemplo n.º 30
0
void
TAO_Transient_Naming_Context::list (CORBA::ULong how_many,
                                    CosNaming::BindingList_out &bl,
                                    CosNaming::BindingIterator_out &bi)
{
  // Allocate nil out parameters in case we won't be able to complete
  // the operation.
  bi = CosNaming::BindingIterator::_nil ();
  ACE_NEW_THROW_EX (bl,
                    CosNaming::BindingList (0),
                    CORBA::NO_MEMORY ());

  // Obtain a lock before we proceed with the operation.
  ACE_GUARD_THROW_EX (TAO_SYNCH_RECURSIVE_MUTEX,
                      ace_mon,
                      this->lock_,
                      CORBA::INTERNAL ());

  // Check to make sure this object didn't have <destroy> method
  // invoked on it.
  if (this->destroyed_)
    throw CORBA::OBJECT_NOT_EXIST ();

  // Dynamically allocate iterator for traversing the underlying hash map.
  HASH_MAP::ITERATOR *hash_iter = 0;
  ACE_NEW_THROW_EX (hash_iter,
                    HASH_MAP::ITERATOR (transient_context_->map ()),
                    CORBA::NO_MEMORY ());

  // Store <hash_iter temporarily in auto pointer, in case we'll have
  // some failures and throw an exception.
  ACE_Auto_Basic_Ptr<HASH_MAP::ITERATOR> temp (hash_iter);

  // Silliness below is required because of broken old g++!!!  E.g.,
  // without it, we could have just said HASH_MAP::ITERATOR everywhere we use ITER_DEF.
  typedef ACE_Hash_Map_Manager<TAO_ExtId, TAO_IntId, ACE_Null_Mutex>::ITERATOR ITER_DEF;
  typedef ACE_Hash_Map_Manager<TAO_ExtId, TAO_IntId, ACE_Null_Mutex>::ENTRY ENTRY_DEF;

  // Typedef to the type of BindingIterator servant for ease of use.
  typedef TAO_Bindings_Iterator<ITER_DEF, ENTRY_DEF>
    ITER_SERVANT;

  // A pointer to BindingIterator servant.
  ITER_SERVANT *bind_iter = 0;

  // Number of bindings that will go into the BindingList <bl>.
  CORBA::ULong n = 0;

  // Calculate number of bindings that will go into <bl>.
  if (this->context_->current_size () > how_many)
    n = how_many;
  else
    n = static_cast<CORBA::ULong> (this->context_->current_size ());

  // Use the hash map iterator to populate <bl> with bindings.
  bl->length (n);

  ENTRY_DEF *hash_entry = 0;

  for (CORBA::ULong i = 0; i < n; i++)
    {
      hash_iter->next (hash_entry);
      hash_iter->advance ();

      if (ITER_SERVANT::populate_binding (hash_entry, bl[i]) == 0)
          throw CORBA::NO_MEMORY();
    }

  // Now we are done with the BindingsList, and we can follow up on
  // the BindingIterator business.

  // If we do not need to pass back BindingIterator.
  if (this->context_->current_size () <= how_many)
    return;
  else
    {
      // Create a BindingIterator for return.
      ACE_NEW_THROW_EX (bind_iter,
                        ITER_SERVANT (this, hash_iter, this->poa_.in (), this->lock_),
                        CORBA::NO_MEMORY ());

      // Release <hash_iter> from auto pointer, and start using
      // reference counting to control our servant.
      temp.release ();
      PortableServer::ServantBase_var iter = bind_iter;

      // Increment reference count on this Naming Context, so it doesn't get
      // deleted before the BindingIterator servant gets deleted.
      interface_->_add_ref ();

      // Register with the POA.
      char poa_id[BUFSIZ];
      ACE_OS::sprintf (poa_id,
                       "%s_%d",
                       this->poa_id_.c_str (),
                       this->counter_++);
#if defined (CORBA_E_MICRO)
      PortableServer::ObjectId_var id =
        this->poa_->activate_object (bind_iter);
#else
      PortableServer::ObjectId_var id =
        PortableServer::string_to_ObjectId (poa_id);

      this->poa_->activate_object_with_id (id.in (), bind_iter);
#endif /* CORBA_E_MICRO */

      bi = bind_iter->_this ();
    }
}