Removed all debug messages from the ANA implementation...
...of the current network API.
This commit is contained in:
parent
d571b76370
commit
3f7fb94529
4 changed files with 4 additions and 68 deletions
|
@ -215,6 +215,9 @@ void asio_listener::handle_raw_buffer( ana::detail::read_buffer buf,
|
|||
{
|
||||
try
|
||||
{
|
||||
delete next_message_timer_;
|
||||
next_message_timer_ = NULL;
|
||||
|
||||
if (ec)
|
||||
disconnect( ec );
|
||||
else
|
||||
|
@ -222,8 +225,6 @@ void asio_listener::handle_raw_buffer( ana::detail::read_buffer buf,
|
|||
buf->resize( read_size );
|
||||
log_conditional_receive( buf );
|
||||
listener_->handle_receive( ec, id(), buf );
|
||||
delete next_message_timer_;
|
||||
next_message_timer_ = NULL;
|
||||
listen_one_message();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ namespace network {
|
|||
|
||||
connection_stats get_connection_stats(connection connection_num)
|
||||
{
|
||||
std::cout << "DEBUG: get_connection_stats\n";
|
||||
const ana::stats* stats = ana_manager.get_stats( connection_num );
|
||||
|
||||
return connection_stats( stats->bytes_out(),
|
||||
|
@ -100,12 +99,10 @@ namespace network {
|
|||
|
||||
error::error(const std::string& msg, connection sock) : message(msg), socket(sock)
|
||||
{
|
||||
std::cout << "DEBUG: error::error\n";
|
||||
}
|
||||
|
||||
void error::disconnect()
|
||||
{
|
||||
std::cout << "DEBUG: error::disconnect\n";
|
||||
}
|
||||
|
||||
pending_statistics get_pending_stats()
|
||||
|
@ -116,13 +113,10 @@ namespace network {
|
|||
manager::manager(size_t /*min_threads*/, size_t /*max_threads*/) : free_(true)
|
||||
{
|
||||
++instances_using_the_network_module;
|
||||
std::cout << "DEBUG: Creating a manager object.\n";
|
||||
}
|
||||
|
||||
manager::~manager()
|
||||
{
|
||||
std::cout << "DEBUG: destroying the manager object.\n";
|
||||
|
||||
if ( --instances_using_the_network_module == 0 )
|
||||
ana_manager.close_connections_and_cleanup();
|
||||
}
|
||||
|
@ -135,7 +129,6 @@ namespace network {
|
|||
: free_(false),
|
||||
connection_(0)
|
||||
{
|
||||
std::cout << "DEBUG: server_manager\n";
|
||||
if ( create_server != NO_SERVER )
|
||||
{
|
||||
ana::net_id server_id = ana_manager.create_server( );
|
||||
|
@ -169,13 +162,11 @@ namespace network {
|
|||
|
||||
connection connect(const std::string& host, int port)
|
||||
{
|
||||
std::cout << "DEBUG: connect\n";
|
||||
return ana_manager.create_client_and_connect( host, port );
|
||||
}
|
||||
|
||||
connection connect(const std::string& host, int port, threading::waiter& /*waiter*/)
|
||||
{
|
||||
std::cout << "DEBUG: connect2\n";
|
||||
return connect( host, port );
|
||||
}
|
||||
|
||||
|
@ -207,9 +198,6 @@ namespace network {
|
|||
|
||||
network::connection read_id = ana_manager.read_from( connection_num, cfg, timeout );
|
||||
|
||||
// if ( read_id != 0 )
|
||||
// std::cout << "Read: " << cfg << "\n";
|
||||
|
||||
// TODO: check timeout and return 0, or throw if error occured
|
||||
|
||||
return read_id;
|
||||
|
@ -249,11 +237,6 @@ namespace network {
|
|||
|
||||
std::string get_bandwidth_stats_all()
|
||||
{
|
||||
std::cout << "DEBUG: get_bandwidth_stats_all() for "
|
||||
<< ana_manager.number_of_connections() << " components.\n";
|
||||
|
||||
|
||||
|
||||
//TODO: packet_type and widths should be modifiable
|
||||
const char* packet_type = "network";
|
||||
|
||||
|
@ -276,9 +259,6 @@ namespace network {
|
|||
|
||||
std::string get_bandwidth_stats()
|
||||
{
|
||||
std::cout << "DEBUG: get_bandwidth_stats() for "
|
||||
<< ana_manager.number_of_connections() << " components.\n";
|
||||
|
||||
//TODO: packet_type and widths should be modifiable
|
||||
const char* packet_type = "network";
|
||||
|
||||
|
@ -301,7 +281,6 @@ namespace network {
|
|||
|
||||
std::string get_bandwidth_stats(int hour)
|
||||
{
|
||||
std::cout << "DEBUG: get_bandwidth_stats with hour " << hour << "\n";
|
||||
return std::string(""); //TODO: implement
|
||||
}
|
||||
|
||||
|
@ -329,8 +308,6 @@ namespace network {
|
|||
if(cfg.empty())
|
||||
return 0;
|
||||
|
||||
// std::cout << "DEBUG: Sending: " << cfg << "\n";
|
||||
|
||||
if( connection_num == 0 )
|
||||
return ana_manager.send_all( cfg, gzipped );
|
||||
else
|
||||
|
@ -342,7 +319,6 @@ namespace network {
|
|||
connection connection_num,
|
||||
const std::string& /*packet_type*/)
|
||||
{
|
||||
// std::cout << "DEBUG: Sending Raw: " << std::string( buf, len ) << "\n";
|
||||
ana_manager.send_raw_data( buf, size_t( len ), connection_num );
|
||||
}
|
||||
|
||||
|
@ -357,19 +333,16 @@ namespace network {
|
|||
const bool /*gzipped*/,
|
||||
const std::string& /*packet_type*/)
|
||||
{
|
||||
// std::cout << "DEBUG: Sending all except " << connection_num << " - " << cfg << "\n";
|
||||
ana_manager.send_all_except(cfg, connection_num);
|
||||
}
|
||||
|
||||
std::string ip_address(connection connection_num)
|
||||
{
|
||||
std::cout << "DEBUG: ip_address\n";
|
||||
return ana_manager.ip_address( connection_num );
|
||||
}
|
||||
|
||||
statistics get_send_stats(connection handle)
|
||||
{
|
||||
std::cout << "DEBUG: get_send_stats\n";
|
||||
return ana_manager.get_send_stats( handle );
|
||||
}
|
||||
|
||||
|
|
|
@ -166,6 +166,7 @@ void client::handle_connect( ana::error_code error, net_id server_id )
|
|||
|
||||
client_->send( ana::buffer( bos.str()), this );
|
||||
|
||||
client_->expecting_message( ana::time::seconds( 10 ) );
|
||||
status_ = PENDING_HANDSHAKE;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,12 @@ ana_send_handler::ana_send_handler( size_t calls ) :
|
|||
target_calls_( calls ),
|
||||
error_code_()
|
||||
{
|
||||
std::cout << "DEBUG: Constructing a new ana_send_handler...\n";
|
||||
if ( calls > 0 )
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
ana_send_handler::~ana_send_handler()
|
||||
{
|
||||
std::cout << "DEBUG: Terminating an ana_send_handler...\n";
|
||||
if ( target_calls_ > 0 )
|
||||
throw std::runtime_error("Handler wasn't called enough times.");
|
||||
mutex_.lock();
|
||||
|
@ -103,7 +101,6 @@ ana_receive_handler::ana_receive_handler( ana_component_set::iterator iterator )
|
|||
receive_timer_( NULL ),
|
||||
finished_( false )
|
||||
{
|
||||
// std::cout << "DEBUG: Constructing a new ana_receive_handler...\n"; // too much output
|
||||
mutex_.lock();
|
||||
timeout_called_mutex_.lock();
|
||||
}
|
||||
|
@ -208,7 +205,6 @@ ana_multiple_receive_handler::ana_multiple_receive_handler( ana_component_set& c
|
|||
finished_( false )
|
||||
{
|
||||
throw std::runtime_error("Multiple receive handler constructed");
|
||||
std::cout << "DEBUG: Constructing a new ana_multiple_receive_handler...\n";
|
||||
|
||||
ana_component_set::iterator it;
|
||||
|
||||
|
@ -319,11 +315,6 @@ void ana_multiple_receive_handler::handle_timeout(ana::error_code error_code)
|
|||
|
||||
if (! finished_ )
|
||||
{
|
||||
if (error_code)
|
||||
std::cout << "DEBUG: Receive attempt timed out\n";
|
||||
else
|
||||
std::cout << "DEBUG: Shouldn't reach here\n";
|
||||
|
||||
error_code_ = error_code;
|
||||
finished_ = true;
|
||||
mutex_.unlock();
|
||||
|
@ -339,13 +330,11 @@ ana_connect_handler::ana_connect_handler( ) :
|
|||
mutex_( ),
|
||||
error_code_()
|
||||
{
|
||||
std::cout << "DEBUG: Constructing a new ana_connect_handler...\n";
|
||||
mutex_.lock();
|
||||
}
|
||||
|
||||
ana_connect_handler::~ana_connect_handler()
|
||||
{
|
||||
std::cout << "DEBUG: Terminating an ana_connect_handler...\n";
|
||||
mutex_.lock();
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
@ -357,11 +346,6 @@ const ana::error_code& ana_connect_handler::error() const
|
|||
|
||||
void ana_connect_handler::handle_connect(ana::error_code error_code, ana::net_id /*client*/)
|
||||
{
|
||||
if (! error_code)
|
||||
std::cout << "DEBUG: Connected.\n";
|
||||
else
|
||||
std::cout << "DEBUG: Can't connect. " << error_code << "\n";
|
||||
|
||||
error_code_ = error_code;
|
||||
mutex_.unlock();
|
||||
}
|
||||
|
@ -549,8 +533,6 @@ size_t clients_manager::client_amount() const
|
|||
|
||||
void clients_manager::handle_connect(ana::error_code error, ana::net_id client)
|
||||
{
|
||||
std::cout << "New client connected with id " << client << "\n";
|
||||
|
||||
if (! error )
|
||||
{
|
||||
ids_.insert( client );
|
||||
|
@ -616,8 +598,6 @@ ana_network_manager::ana_network_manager() :
|
|||
|
||||
ana::net_id ana_network_manager::create_server( )
|
||||
{
|
||||
std::cout << "DEBUG: Creating server.\n";
|
||||
|
||||
ana_component* new_component = new ana_component( );
|
||||
components_.insert( new_component );
|
||||
|
||||
|
@ -635,8 +615,6 @@ ana::net_id ana_network_manager::create_server( )
|
|||
|
||||
network::connection ana_network_manager::create_client_and_connect(std::string host, int port)
|
||||
{
|
||||
std::cout << "DEBUG: Creating client and connecting...\n";
|
||||
|
||||
try
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
@ -688,7 +666,6 @@ network::connection ana_network_manager::create_client_and_connect(std::string h
|
|||
|
||||
bis >> my_id;
|
||||
ana::network_to_host_long( my_id );
|
||||
std::cout << "DEBUG: Received id " << my_id << "\n";
|
||||
|
||||
new_component->set_wesnoth_id( my_id );
|
||||
|
||||
|
@ -701,7 +678,6 @@ network::connection ana_network_manager::create_client_and_connect(std::string h
|
|||
}
|
||||
catch( const std::exception& e )
|
||||
{
|
||||
std::cout << "DEBUG: Caught an exception while trying to connect.\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -860,8 +836,6 @@ void ana_network_manager::read_config( const ana::detail::read_buffer& buffer, c
|
|||
|
||||
size_t ana_network_manager::send_all( const config& cfg, bool zipped )
|
||||
{
|
||||
std::cout << "DEBUG: Sending to everybody. " << (zipped ? "Zipped":"Raw") << "\n";
|
||||
|
||||
const std::string output_string = compress_config(cfg);
|
||||
|
||||
std::set<ana_component*>::iterator it;
|
||||
|
@ -884,7 +858,6 @@ size_t ana_network_manager::send_all( const config& cfg, bool zipped )
|
|||
handler.wait_completion();
|
||||
}
|
||||
}
|
||||
std::cout << "Sent data.\n";
|
||||
return output_string.size();
|
||||
}
|
||||
|
||||
|
@ -895,8 +868,6 @@ size_t ana_network_manager::send( network::connection connection_num ,
|
|||
if ( ! zipped )
|
||||
throw std::runtime_error("All send operations should be zipped");
|
||||
|
||||
std::cout << "DEBUG: Single send...\n";
|
||||
|
||||
const std::string output_string = compress_config(cfg);
|
||||
|
||||
|
||||
|
@ -949,8 +920,6 @@ size_t ana_network_manager::send_raw_data( const char* base_char,
|
|||
|
||||
void ana_network_manager::send_all_except(const config& cfg, network::connection connection_num)
|
||||
{
|
||||
std::cout << "DEBUG: send_all_except " << connection_num << "\n";
|
||||
|
||||
const std::string output_string = compress_config(cfg);
|
||||
|
||||
|
||||
|
@ -1124,8 +1093,6 @@ network::connection ana_network_manager::read_from_all( std::vector<char>& vec)
|
|||
|
||||
network::statistics ana_network_manager::get_send_stats(network::connection handle)
|
||||
{
|
||||
std::cout << "DEBUG: in get_send_stats to " << handle << "\n";
|
||||
|
||||
if ( handle != 0 )
|
||||
{
|
||||
ana::net_id id( handle );
|
||||
|
@ -1188,9 +1155,6 @@ void ana_network_manager::handle_receive( ana::error_code error,
|
|||
network::disconnect( client );
|
||||
else
|
||||
{
|
||||
std::cout << "DEBUG: Buffer received with size " << buffer->size()
|
||||
<< " from " << client << "\n";
|
||||
|
||||
std::set< ana_component* >::iterator it;
|
||||
|
||||
it = std::find_if( components_.begin(), components_.end(),
|
||||
|
@ -1269,8 +1233,6 @@ bool ana_component::new_buffer_ready() // non const due to mutex block
|
|||
|
||||
void ana_network_manager::handle_disconnect(ana::error_code /*error_code*/, ana::net_id client)
|
||||
{
|
||||
std::cout << "DEBUG: Disconnected from server.\n";
|
||||
|
||||
std::set< ana_component* >::iterator it;
|
||||
|
||||
it = std::find_if( components_.begin(), components_.end(),
|
||||
|
@ -1278,7 +1240,6 @@ void ana_network_manager::handle_disconnect(ana::error_code /*error_code*/, ana:
|
|||
|
||||
if ( it != components_.end() )
|
||||
{
|
||||
std::cout << "DEBUG: Removing bad component.\n";
|
||||
// close_connections_and_cleanup();
|
||||
delete *it;
|
||||
components_.erase(it);
|
||||
|
|
Loading…
Add table
Reference in a new issue