Beispiel #1
0
void
flow_ssh_master_connect (FlowSshMaster *ssh_master)
{
  FlowSshMasterPrivate *priv;

  g_return_if_fail (FLOW_IS_SSH_MASTER (ssh_master));

  priv = ssh_master->priv;

  g_mutex_lock (priv->mutex);

  if (priv->is_connecting)
    goto out;

  if (!is_master_supported (ssh_master))
    priv->is_connected = TRUE;

  if (priv->is_connected)
  {
    if (priv->fake_connect_idle_id == 0)
      priv->fake_connect_idle_id = flow_idle_add_to_current_thread ((GSourceFunc) confirm_already_connected, ssh_master);
  }
  else
  {
    g_clear_error (&priv->connect_error);
    connect_begin (ssh_master);
  }

out:
  g_mutex_unlock (priv->mutex);
}
Beispiel #2
0
    parcelport_connection_ptr parcelport::create_connection(
        naming::locality const& l, error_code& ec)
    {
        boost::asio::io_service& io_service = io_service_pool_.get_io_service();

        // The parcel gets serialized inside the connection constructor, no
        // need to keep the original parcel alive after this call returned.
        parcelport_connection_ptr client_connection(
            new parcelport_connection(io_service, here_, l,
                data_buffer_cache_, parcels_sent_, ++connection_count_));

        // Connect to the target locality, retry if needed
        boost::system::error_code error = boost::asio::error::try_again;
        for (std::size_t i = 0; i < HPX_MAX_NETWORK_RETRIES; ++i)
        {
            try {
                naming::locality::iterator_type end = connect_end(l);
                for (naming::locality::iterator_type it =
                        connect_begin(l, io_service);
                      it != end; ++it)
                {
                    boost::asio::ip::tcp::endpoint const& ep = *it;
                    std::string fullname(ep.address().to_string() + "." +
                        boost::lexical_cast<std::string>(ep.port()));

                    parcelset::shmem::data_window& w = client_connection->window();
                    w.close();
                    w.connect(fullname, error);
                    if (!error)
                        break;
                }
                if (!error)
                    break;

                // wait for a really short amount of time
                this_thread::suspend();
            }
            catch (boost::system::system_error const& e) {
                client_connection->window().close();
                client_connection.reset();

                HPX_THROWS_IF(ec, network_error,
                    "shmem::parcelport::get_connection", e.what());
                return client_connection;
            }
        }

        if (error) {
            client_connection->window().close();
            client_connection.reset();

            hpx::util::osstream strm;
            strm << error.message() << " (while trying to connect to: "
                  << l << ")";
            HPX_THROWS_IF(ec, network_error,
                "shmem::parcelport::get_connection",
                hpx::util::osstream_get_string(strm));
            return client_connection;
        }

        if (&ec != &throws)
            ec = make_success_code();

        return client_connection;
    }
    parcelport_connection_ptr parcelport::create_connection(
        naming::locality const& l, error_code& ec)
    {
        boost::asio::io_service& io_service = io_service_pool_.get_io_service();

        // The parcel gets serialized inside the connection constructor, no
        // need to keep the original parcel alive after this call returned.
        parcelport_connection_ptr client_connection(new parcelport_connection(
            io_service, l, parcels_sent_));

        // Connect to the target locality, retry if needed
        boost::system::error_code error = boost::asio::error::try_again;
        for (std::size_t i = 0; i < HPX_MAX_NETWORK_RETRIES; ++i)
        {
            try {
                naming::locality::iterator_type end = connect_end(l);
                for (naming::locality::iterator_type it =
                        connect_begin(l, io_service);
                      it != end; ++it)
                {
                    boost::asio::ip::tcp::endpoint const& ep = *it;

                    parcelset::ibverbs::client_context& ctx = client_connection->context();
                    ctx.close();
                    ctx.connect(ep, error);
                    if (!error)
                        break;
                }
                if (!error)
                    break;

                // wait for a really short amount of time
                if (hpx::threads::get_self_ptr()) {
                    this_thread::suspend();
                }
                else {
                    boost::this_thread::sleep(boost::get_system_time() +
                        boost::posix_time::milliseconds(
                            HPX_NETWORK_RETRIES_SLEEP));
                }
            }
            catch (boost::system::system_error const& e) {
                client_connection->context().close();
                client_connection.reset();

                HPX_THROWS_IF(ec, network_error,
                    "ibverbs::parcelport::get_connection", e.what());
                return client_connection;
            }
        }

        if (error) {
            client_connection->context().close();
            client_connection.reset();

            hpx::util::osstream strm;
            strm << error.message() << " (while trying to connect to: "
                  << l << ")";

            HPX_THROWS_IF(ec, network_error,
                "ibverbs::parcelport::get_connection",
                hpx::util::osstream_get_string(strm));
            return client_connection;
        }

        if (&ec != &throws)
            ec = make_success_code();

        return client_connection;
    }
boost::shared_ptr<sender> connection_handler::create_connection(
    naming::locality const& l, error_code& ec)
{
    boost::asio::io_service& io_service = io_service_pool_.get_io_service(0);
    boost::shared_ptr<sender> sender_connection(new sender(*this, memory_pool_, l, parcels_sent_));

    // Connect to the target locality, retry if needed
    boost::system::error_code error = boost::asio::error::try_again;
    for (std::size_t i = 0; i < HPX_MAX_NETWORK_RETRIES; ++i)
    {
        try {
            naming::locality::iterator_type end = connect_end(l);
            for (naming::locality::iterator_type it =
                        connect_begin(l, io_service, true);
                    it != end; ++it)
            {
                boost::asio::ip::tcp::endpoint const& ep = *it;

                client_context& ctx = sender_connection->context();
                ctx.close(ec);
                ctx.connect(*this, ep, error);
                if (!error)
                    break;
            }
            if (!error)
                break;

            // wait for a really short amount of time
            if (hpx::threads::get_self_ptr()) {
                this_thread::suspend(hpx::threads::pending,
                                     "connection_handler(ibverbs)::create_connection");
            }
            else {
                boost::this_thread::sleep(boost::get_system_time() +
                                          boost::posix_time::milliseconds(
                                              HPX_NETWORK_RETRIES_SLEEP));
            }
        }
        catch (boost::system::system_error const& e) {
            sender_connection->context().close(ec);
            sender_connection.reset();

            HPX_THROWS_IF(ec, network_error,
                          "ibverbs::parcelport::create_connection", e.what());
            return sender_connection;
        }
    }

    if (error) {
        sender_connection->context().close(ec);
        sender_connection.reset();

        hpx::util::osstream strm;
        strm << error.message() << " (while trying to connect to: "
             << l << ")";

        HPX_THROWS_IF(ec, network_error,
                      "ibverbs::parcelport::create_connection",
                      hpx::util::osstream_get_string(strm));
        return sender_connection;
    }

    if (&ec != &throws)
        ec = make_success_code();

    return sender_connection;
}
Beispiel #5
0
 endpoint_iterator_type connect_begin(Locality const& loc,
     boost::asio::io_service& io_service)
 {
     return connect_begin(loc.address(), loc.port(), io_service);
 }