Esempio n. 1
0
void connection_manager::start(connection_ptr c)
{
	connections_.insert(c);

	boost::system::error_code ec;
	boost::asio::ip::tcp::endpoint endpoint = c->socket().remote_endpoint(ec);
	if (ec) {
		// Prevent the exception to be thrown to run to avoid the server to be locked (still listening but no more connection or stop).
		// If the exception returns to WebServer to also create a exception loop.
		_log.Log(LOG_ERROR,"Getting error '%s' while getting remote_endpoint in connection_manager::start", ec.message().c_str());
		stop(c);
		return;
	}

	std::string s = endpoint.address().to_string();
	if (s.substr(0, 7) == "::ffff:") {
		s = s.substr(7);
	}
	if (connectedips_.find(s) == connectedips_.end())
	{
		//ok, this could get a very long list when running for years
		connectedips_.insert(s);
		_log.Log(LOG_STATUS,"Incoming connection from: %s", s.c_str());
	}

	c->start();
}
Esempio n. 2
0
    /// Handler callback for start_accept
    void handle_accept(connection_ptr con, lib::error_code const & ec) {
        if (ec) {
            con->terminate(ec);

            if (ec == error::operation_canceled) {
                endpoint_type::m_elog.write(log::elevel::info,
                    "handle_accept error: "+ec.message());
            } else {
                endpoint_type::m_elog.write(log::elevel::rerror,
                    "handle_accept error: "+ec.message());
            }
        } else {
            con->start();
        }

        lib::error_code start_ec;
        start_accept(start_ec);
        if (start_ec == error::async_accept_not_listening) {
            endpoint_type::m_elog.write(log::elevel::info,
                "Stopping acceptance of new connections because the underlying transport is no longer listening.");
        } else if (start_ec) {
            endpoint_type::m_elog.write(log::elevel::rerror,
                "Restarting async_accept loop failed: "+ec.message());
        }
    }
Esempio n. 3
0
  void handle_accept(boost::system::error_code const &ec) {
    {
      scoped_mutex_lock stopping_lock(stopping_mutex_);
      if (stopping)
        return;  // we dont want to add another handler instance, and we
                 // dont want to know about errors for a socket we dont
                 // need anymore
    }

    if (ec) {
      BOOST_NETWORK_MESSAGE("Error accepting connection, reason: " << ec);
    }

#ifdef BOOST_NETWORK_ENABLE_HTTPS
    socket_options_base::socket_options(new_connection->socket().next_layer());
#else
    socket_options_base::socket_options(new_connection->socket());
#endif

    new_connection->start();
    new_connection.reset(new connection(service_, handler, *thread_pool, ctx_));
    acceptor.async_accept(
#ifdef BOOST_NETWORK_ENABLE_HTTPS
        new_connection->socket().next_layer(),
#else
        new_connection->socket(),
#endif
        boost::bind(&async_server_base<Tag, Handler>::handle_accept, this,
                    boost::asio::placeholders::error));
  }
Esempio n. 4
0
	inline void server::handle_accept(const boost::system::error_code& e) {
	    if (!e) {
		new_connection_->start();
		new_connection_.reset(new connection(io_service_, request_handler_));
		acceptor_.async_accept(new_connection_->socket(),
				       boost::bind(&server::handle_accept, this,
						   boost::asio::placeholders::error));
	    }
	}
Esempio n. 5
0
void connection_manager::start(connection_ptr c)
{
  connections_.insert(c);
  c->start();
}
void connection_manager::start(connection_ptr c)
{
    std::lock_guard<std::mutex> lock(mutex_);
    connections_.insert(c);
    c->start();
}
Esempio n. 7
0
 void handle_connect(connection_ptr con, websocketpp::lib::error_code const & ec)
 {
     BOOST_CHECK( !ec );
     con->start();
 }
void ConnectionManager::start(connection_ptr c)
{
	m_connections.insert(c);
	c->start();
}
Esempio n. 9
0
 void handle_connect(connection_ptr con, websocketpp::lib::error_code const & ec)
 {
     boost_check( !ec );
     con->start();
 }