mirror of
https://github.com/monero-project/monero.git
synced 2025-08-11 18:40:11 -04:00
Merge pull request #4489
00901e9c
epee: initialize a few data members where it seems to be appropriate (moneromooo-monero)144a6c32
abstract_tcp_server2: move m_period to subclass (moneromooo-monero)758d7684
connection_basic: remove unused floating time start time (moneromooo-monero)e5108a29
Catch more exceptions in dtors (moneromooo-monero)
This commit is contained in:
commit
5ccd3d32b4
22 changed files with 53 additions and 17 deletions
|
@ -246,7 +246,6 @@ namespace net_utils
|
|||
m_timer(io_serice)
|
||||
{}
|
||||
boost::asio::deadline_timer m_timer;
|
||||
uint64_t m_period;
|
||||
};
|
||||
|
||||
template <class t_handler>
|
||||
|
@ -262,25 +261,27 @@ namespace net_utils
|
|||
{
|
||||
return m_handler();
|
||||
}
|
||||
uint64_t m_period;
|
||||
};
|
||||
|
||||
template<class t_handler>
|
||||
bool add_idle_handler(t_handler t_callback, uint64_t timeout_ms)
|
||||
{
|
||||
boost::shared_ptr<idle_callback_conext_base> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
|
||||
boost::shared_ptr<idle_callback_conext<t_handler>> ptr(new idle_callback_conext<t_handler>(io_service_, t_callback, timeout_ms));
|
||||
//needed call handler here ?...
|
||||
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
|
||||
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
|
||||
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext_base> ptr)
|
||||
template<class t_handler>
|
||||
bool global_timer_handler(/*const boost::system::error_code& err, */boost::shared_ptr<idle_callback_conext<t_handler>> ptr)
|
||||
{
|
||||
//if handler return false - he don't want to be called anymore
|
||||
if(!ptr->call_handler())
|
||||
return true;
|
||||
ptr->m_timer.expires_from_now(boost::posix_time::milliseconds(ptr->m_period));
|
||||
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler, this, ptr));
|
||||
ptr->m_timer.async_wait(boost::bind(&boosted_tcp_server<t_protocol_handler>::global_timer_handler<t_handler>, this, ptr));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ class connection_basic { // not-templated base class for rapid developmet of som
|
|||
critical_section m_send_que_lock;
|
||||
std::list<std::string> m_send_que;
|
||||
volatile bool m_is_multithreaded;
|
||||
double m_start_time;
|
||||
/// Strand to ensure the connection's handlers are not called concurrently.
|
||||
boost::asio::io_service::strand strand_;
|
||||
/// Socket for the connection.
|
||||
|
@ -112,8 +111,6 @@ class connection_basic { // not-templated base class for rapid developmet of som
|
|||
void logger_handle_net_write(size_t size); // network data written
|
||||
void logger_handle_net_read(size_t size); // network data read
|
||||
|
||||
void set_start_time();
|
||||
|
||||
// config for rate limit
|
||||
|
||||
static void set_rate_up_limit(uint64_t limit);
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
size_t get_connections_count();
|
||||
void set_handler(levin_commands_handler<t_connection_context>* handler, void (*destroy)(levin_commands_handler<t_connection_context>*) = NULL);
|
||||
|
||||
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE)
|
||||
async_protocol_handler_config():m_pcommands_handler(NULL), m_pcommands_handler_destroy(NULL), m_max_packet_size(LEVIN_DEFAULT_MAX_PACKET_SIZE), m_invoke_timeout(LEVIN_DEFAULT_TIMEOUT_PRECONFIGURED)
|
||||
{}
|
||||
~async_protocol_handler_config() { set_handler(NULL, NULL); }
|
||||
void del_out_connections(size_t count);
|
||||
|
@ -272,6 +272,8 @@ public:
|
|||
m_wait_count = 0;
|
||||
m_oponent_protocol_ver = 0;
|
||||
m_connection_initialized = false;
|
||||
m_invoke_buf_ready = 0;
|
||||
m_invoke_result_code = LEVIN_ERROR_CONNECTION;
|
||||
}
|
||||
virtual ~async_protocol_handler()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue