mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 03:59:33 +00:00
Merge pull request #5162
4d3b61a3
Use io_service::work in epee tcp server (Lee Clagett)
This commit is contained in:
commit
c83e80c263
2 changed files with 14 additions and 6 deletions
|
@ -347,7 +347,16 @@ namespace net_utils
|
||||||
const boost::shared_ptr<typename connection<t_protocol_handler>::shared_state> m_state;
|
const boost::shared_ptr<typename connection<t_protocol_handler>::shared_state> m_state;
|
||||||
|
|
||||||
/// The io_service used to perform asynchronous operations.
|
/// The io_service used to perform asynchronous operations.
|
||||||
std::unique_ptr<boost::asio::io_service> m_io_service_local_instance;
|
struct worker
|
||||||
|
{
|
||||||
|
worker()
|
||||||
|
: io_service(), work(io_service)
|
||||||
|
{}
|
||||||
|
|
||||||
|
boost::asio::io_service io_service;
|
||||||
|
boost::asio::io_service::work work;
|
||||||
|
};
|
||||||
|
std::unique_ptr<worker> m_io_service_local_instance;
|
||||||
boost::asio::io_service& io_service_;
|
boost::asio::io_service& io_service_;
|
||||||
|
|
||||||
/// Acceptor used to listen for incoming connections.
|
/// Acceptor used to listen for incoming connections.
|
||||||
|
|
|
@ -891,8 +891,8 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
||||||
template<class t_protocol_handler>
|
template<class t_protocol_handler>
|
||||||
boosted_tcp_server<t_protocol_handler>::boosted_tcp_server( t_connection_type connection_type ) :
|
boosted_tcp_server<t_protocol_handler>::boosted_tcp_server( t_connection_type connection_type ) :
|
||||||
m_state(boost::make_shared<typename connection<t_protocol_handler>::shared_state>()),
|
m_state(boost::make_shared<typename connection<t_protocol_handler>::shared_state>()),
|
||||||
m_io_service_local_instance(new boost::asio::io_service()),
|
m_io_service_local_instance(new worker()),
|
||||||
io_service_(*m_io_service_local_instance.get()),
|
io_service_(m_io_service_local_instance->io_service),
|
||||||
acceptor_(io_service_),
|
acceptor_(io_service_),
|
||||||
default_remote(),
|
default_remote(),
|
||||||
m_stop_signal_sent(false), m_port(0),
|
m_stop_signal_sent(false), m_port(0),
|
||||||
|
@ -1005,9 +1005,8 @@ POP_WARNINGS
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
size_t cnt = io_service_.run();
|
io_service_.run();
|
||||||
if (cnt == 0)
|
return true;
|
||||||
misc_utils::sleep_no_w(1);
|
|
||||||
}
|
}
|
||||||
catch(const std::exception& ex)
|
catch(const std::exception& ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue