예제 #1
0
TAO_IIOP_Connection_Handler::~TAO_IIOP_Connection_Handler (void)
{
  if (TAO_debug_level > 9)
    {
      TAO_Transport *tport = this->transport ();
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT("TAO (%P|%t) - IIOP_Connection_Handler[%d]::")
                  ACE_TEXT("~IIOP_Connection_Handler, ")
                  ACE_TEXT("this=%@, transport=%@\n"),
                  tport != 0 ? tport->id () : 0,
                  this,
                  tport));
    }
  delete this->transport ();
  int const result =
    this->release_os_resources ();

  if (result == -1 && TAO_debug_level)
    {
      TAOLIB_ERROR ((LM_ERROR,
                  ACE_TEXT("TAO (%P|%t) - IIOP_Connection_Handler::")
                  ACE_TEXT("~IIOP_Connection_Handler, ")
                  ACE_TEXT("release_os_resources() failed %m\n")));
    }
}
예제 #2
0
ACE_Event_Handler::Reference_Count
TAO_IIOP_Connection_Handler::remove_reference (void)
{
  TAO_Transport *tport = this->transport ();
  Reference_Count rc = TAO_IIOP_SVC_HANDLER::remove_reference ();
  if (TAO_debug_level > 9)
    {
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT("TAO (%P|%t) - IIOP_Connection_Handler[%d]::")
                  ACE_TEXT("remove_reference, down to %d\n"),
                  tport != 0 ? tport->id () : 0,
                  rc));
    }
  return rc;
}
예제 #3
0
TAO_BEGIN_VERSIONED_NAMESPACE_DECL


#ifdef TAO_LOG_CH_REF_COUNTS
ACE_Event_Handler::Reference_Count
TAO_IIOP_Connection_Handler::add_reference (void)
{
  Reference_Count rc = TAO_IIOP_SVC_HANDLER::add_reference ();
  if (TAO_debug_level > 9)
    {
      TAO_Transport *tport = this->transport ();
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT("TAO (%P|%t) - IIOP_Connection_Handler[%d]::")
                  ACE_TEXT("add_reference, up to %d\n"),
                  tport != 0 ? tport->id () : 0,
                  rc));
    }
  return rc;

}
예제 #4
0
TAO_IIOP_Connection_Handler::TAO_IIOP_Connection_Handler (
  TAO_ORB_Core *orb_core)
  : TAO_IIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
    TAO_Connection_Handler (orb_core),
    dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2)
{
  TAO_IIOP_Transport* specific_transport = 0;
  ACE_NEW (specific_transport,
           TAO_IIOP_Transport (this, orb_core));

  if (TAO_debug_level > 9)
    {
      TAO_Transport *tport = static_cast<TAO_Transport *> (specific_transport);
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT("TAO (%P|%t) - IIOP_Connection_Handler[%d]::")
                  ACE_TEXT("IIOP_Connection_Handler, ")
                  ACE_TEXT("this=%@\n"),
                  tport != 0 ? tport->id () : 0,
                  this));
    }

  // store this pointer (indirectly increment ref count)
  this->transport (specific_transport);
}
예제 #5
0
TAO_Transport *
TAO_UIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *r,
                                     TAO_Transport_Descriptor_Interface &desc,
                                     ACE_Time_Value *max_wait_time)
{
  if (TAO_debug_level > 0)
    TAOLIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - UIUP_Connector::make_connection, ")
                ACE_TEXT ("looking for UIOP connection.\n")));

  TAO_UIOP_Endpoint *uiop_endpoint =
    this->remote_endpoint (desc.endpoint ());

  if (uiop_endpoint == 0)
    return 0;

  const ACE_UNIX_Addr &remote_address =
    uiop_endpoint->object_addr ();

  if (TAO_debug_level > 2)
    TAOLIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - UIUP_Connector::make_connection, ")
                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);

  // The code used to set the timeout to zero, with the intent of
  // polling the reactor for connection completion. However, the side-effect
  // was to cause the connection to timeout immediately.

  TAO_UIOP_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)
                TAOLIB_ERROR ((LM_ERROR, "TAO (%P|%t) - UIOP_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 > 3)
          TAOLIB_ERROR ((LM_ERROR,
                      "TAO (%P|%t) - UIOP_Connector::make_connection, "
                      "connection to <%C> failed (%p)\n",
                      uiop_endpoint->rendezvous_point (),
                      ACE_TEXT("errno")));

      return 0;
    }

  if (svc_handler->keep_waiting ())
    {
      svc_handler->connection_pending ();
    }

  if (svc_handler->error_detected ())
    {
      svc_handler->cancel_pending_connection ();
    }

  // At this point, the connection has be successfully created
  // connected or not connected, but we have a connection.
  if (TAO_debug_level > 2)
    TAOLIB_DEBUG ((LM_DEBUG,
                "TAO (%P|%t) - UIOP_Connector::make_connection, "
                "new %C connection to <%C> on Transport[%d]\n",
                transport->is_connected() ? "connected" : "not connected",
                uiop_endpoint->rendezvous_point (),
                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)
        {
          TAOLIB_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) - UIOP_Connector::make_connection, ")
                      ACE_TEXT ("could not add the new connection to Cache\n")));
        }

      return 0;
    }

  if (svc_handler->error_detected ())
    {
      svc_handler->cancel_pending_connection ();
      transport->purge_entry();
      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)
        TAOLIB_ERROR ((LM_ERROR,
                    "TAO (%P|%t) - UIOP_Connector [%d]::make_connection, "
                    "could not register the transport "
                    "in the reactor.\n",
                    transport->id ()));

      return 0;
    }

  svc_handler_auto_ptr.release ();
  return transport;
}
예제 #6
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;
}
예제 #7
0
TAO_Transport *
TAO_SHMIOP_Connector::make_connection (TAO::Profile_Transport_Resolver *,
                                       TAO_Transport_Descriptor_Interface &desc,
                                       ACE_Time_Value *timeout)
{
  if (TAO_debug_level > 0)
      TAOLIB_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - SHMIOP_Connector::make_connection, ")
                  ACE_TEXT ("looking for SHMIOP connection.\n")));

  TAO_SHMIOP_Endpoint *shmiop_endpoint =
    this->remote_endpoint (desc.endpoint ());

  if (shmiop_endpoint == 0)
    return 0;

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

  if (TAO_debug_level > 2)
    TAOLIB_DEBUG ((LM_DEBUG,
                "TAO (%P|%t) - SHMIOP_Connector::make_connection, "
                "making a new connection to <%C:%d>\n",
                shmiop_endpoint->host (),
                shmiop_endpoint->port ()));

  // Get the right synch options
  ACE_Synch_Options synch_options;

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

  TAO_SHMIOP_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);

  // In case of errors.
  if (result == -1)
    {
      // Give users a clue to the problem.
      if (TAO_debug_level > 0)
        {
          TAOLIB_ERROR ((LM_ERROR,
                      ACE_TEXT ("TAO (%P|%t) - SHMIOP_Connector::make_connection, ")
                      ACE_TEXT ("connection to <%C:%u> failed (%p)\n"),
                      shmiop_endpoint->host (),
                      shmiop_endpoint->port (),
                      ACE_TEXT ("errno")));
        }

      return 0;
    }

  if (svc_handler->keep_waiting ())
    {
      svc_handler->connection_pending ();
    }

  if (svc_handler->error_detected ())
    {
      svc_handler->cancel_pending_connection ();
    }

  TAO_Transport *transport =
    svc_handler->transport ();

  // At this point, the connection has be successfully connected.
  // #REFCOUNT# is one.
  if (TAO_debug_level > 2)
    TAOLIB_DEBUG ((LM_DEBUG,
                "TAO (%P|%t) - SHMIOP_Connector::make_connection, "
                "new %C connection to <%C:%d> on Transport[%d]\n",
                transport->is_connected() ? "connected" : "not connected",
                shmiop_endpoint->host (),
                shmiop_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)
        {
          TAOLIB_ERROR ((LM_ERROR,
                      ACE_TEXT("TAO (%P|%t) - SHMIOP_Connector::make_connection, ")
                      ACE_TEXT("could not add the new connection to cache\n")));
        }

      return 0;
    }

  if (svc_handler->error_detected ())
    {
      svc_handler->cancel_pending_connection ();
      transport->purge_entry();
      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)
        TAOLIB_ERROR ((LM_ERROR,
                    "TAO (%P|%t) - SHMIOP_Connector [%d]::make_connection, "
                    "could not register the transport in the reactor.\n",
                    transport->id ()));

      return 0;
    }

  svc_handler_auto_ptr.release ();
  return transport;
}