Пример #1
0
void session_batch::start_connect(const code& ec, const authority& host,
    connector::ptr connect, atomic_counter_ptr counter, channel_handler handler)
{
    if (counter->load() == batch_size_)
        return;

    // This termination prevents a tight loop in the empty address pool case.
    if (ec)
    {
        log::error(LOG_NETWORK)
            << "Failure fetching new address: " << ec.message();
        handler(ec, nullptr);
        return;
    }

    // This creates a tight loop in the case of a small address pool.
    if (blacklisted(host))
    {
        log::debug(LOG_NETWORK)
            << "Fetched blacklisted address [" << host << "] ";
        handler(error::address_blocked, nullptr);
        return;
    }

    log::debug(LOG_NETWORK)
        << "Connecting to [" << host << "]";

    // CONNECT
    connect->connect(host, BIND6(handle_connect, _1, _2, host, connect,
        counter, handler));
}
Пример #2
0
void session_batch::start_connect(const code& ec, const authority& host,
    connector::ptr connect, channel_handler handler)
{
    if (stopped() || ec == error::service_stopped)
    {
        LOG_DEBUG(LOG_NETWORK)
            << "Batch session stopped while starting.";
        handler(error::service_stopped, nullptr);
        return;
    }

    // This termination prevents a tight loop in the empty address pool case.
    if (ec)
    {
        LOG_WARNING(LOG_NETWORK)
            << "Failure fetching new address: " << ec.message();
        handler(ec, nullptr);
        return;
    }

    // This creates a tight loop in the case of a small address pool.
    if (blacklisted(host))
    {
        LOG_DEBUG(LOG_NETWORK)
            << "Fetched blacklisted address [" << host << "] ";
        handler(error::address_blocked, nullptr);
        return;
    }

    LOG_DEBUG(LOG_NETWORK)
        << "Connecting to [" << host << "]";

    // CONNECT
    connect->connect(host, handler);
}
Пример #3
0
void session_outbound::start_connect(const code& ec, const authority& host,
    connector::ptr connect)
{
    if (stopped())
        return;

    // This prevents a tight loop in an unusual circumstance.
    // TODO: rebuild connection count once addresses are found.
    if (ec == error::not_found)
    {
        log::error(LOG_NETWORK)
            << "The address pool is empty, suspending outbound session.";
        return;
    }

    if (ec)
    {
        log::error(LOG_NETWORK)
            << "Failure fetching new address: " << ec.message();
        new_connection(connect);
        return;
    }

    // This could create a tight loop in the case of a small pool.
    if (blacklisted(host))
    {
        log::debug(LOG_NETWORK)
            << "Fetched blacklisted address [" << host << "] ";
        new_connection(connect);
        return;
    }

    log::debug(LOG_NETWORK)
        << "Connecting to channel [" << host << "]";

    // OUTBOUND CONNECT
    connect->connect(host,
        dispatch_.ordered_delegate(&session_outbound::handle_connect,
            shared_from_base<session_outbound>(), _1, _2, host, connect));
}
Пример #4
0
void p2p::unpend(connector::ptr connector)
{
    connector->stop(error::success);
    pending_connect_.remove(connector);
}
Пример #5
0
void session::do_stop_connector(const code&, connector::ptr connect)
{
    connect->stop();
}