Merge pull request #5328

17769db9 epee: fix build with boost 1.70.0 (moneromooo-monero)
d6d6c46c cmake: handle detecting boost using boost's own cmake files (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-03-21 14:39:08 +02:00
commit 190601e517
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
3 changed files with 27 additions and 9 deletions

View File

@ -887,10 +887,16 @@ find_package(Boost 1.58 QUIET REQUIRED COMPONENTS system filesystem thread date_
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES}) set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND) if(NOT Boost_FOUND)
die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (1.58) or the equivalent") die("Could not find Boost libraries, please make sure you have installed Boost or libboost-all-dev (>=1.58) or the equivalent")
elseif(Boost_FOUND) elseif(Boost_FOUND)
message(STATUS "Found Boost Version: ${Boost_VERSION}") message(STATUS "Found Boost Version: ${Boost_VERSION}")
if (Boost_VERSION VERSION_LESS 106200 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1)) if (Boost_VERSION VERSION_LESS 10 AND Boost_VERSION VERSION_LESS 1.62.0 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1))
set(BOOST_BEFORE_1_62 true)
endif()
if (NOT Boost_VERSION VERSION_LESS 10 AND Boost_VERSION VERSION_LESS 106200 AND NOT (OPENSSL_VERSION VERSION_LESS 1.1))
set(BOOST_BEFORE_1_62 true)
endif()
if (BOOST_BEFORE_1_62)
message(FATAL_ERROR "Boost older than 1.62 is too old to link with OpenSSL 1.1 or newer. " message(FATAL_ERROR "Boost older than 1.62 is too old to link with OpenSSL 1.1 or newer. "
"Update Boost or install OpenSSL 1.0 and set path to it when running cmake: " "Update Boost or install OpenSSL 1.0 and set path to it when running cmake: "
"cmake -DOPENSSL_ROOT_DIR='/usr/include/openssl-1.0;/usr/lib/openssl-1.0'") "cmake -DOPENSSL_ROOT_DIR='/usr/include/openssl-1.0;/usr/lib/openssl-1.0'")

View File

@ -58,6 +58,12 @@
#define DEFAULT_TIMEOUT_MS_REMOTE 300000 // 5 minutes #define DEFAULT_TIMEOUT_MS_REMOTE 300000 // 5 minutes
#define TIMEOUT_EXTRA_MS_PER_BYTE 0.2 #define TIMEOUT_EXTRA_MS_PER_BYTE 0.2
#if BOOST_VERSION >= 107000
#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
#else
#define GET_IO_SERVICE(s) ((s).get_io_service())
#endif
PRAGMA_WARNING_PUSH PRAGMA_WARNING_PUSH
namespace epee namespace epee
{ {
@ -99,7 +105,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
m_connection_type( connection_type ), m_connection_type( connection_type ),
m_throttle_speed_in("speed_in", "throttle_speed_in"), m_throttle_speed_in("speed_in", "throttle_speed_in"),
m_throttle_speed_out("speed_out", "throttle_speed_out"), m_throttle_speed_out("speed_out", "throttle_speed_out"),
m_timer(socket_.get_io_service()), m_timer(GET_IO_SERVICE(socket_)),
m_local(false), m_local(false),
m_ready_to_close(false) m_ready_to_close(false)
{ {
@ -243,7 +249,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
template<class t_protocol_handler> template<class t_protocol_handler>
boost::asio::io_service& connection<t_protocol_handler>::get_io_service() boost::asio::io_service& connection<t_protocol_handler>::get_io_service()
{ {
return socket().get_io_service(); return GET_IO_SERVICE(socket());
} }
//--------------------------------------------------------------------------------- //---------------------------------------------------------------------------------
template<class t_protocol_handler> template<class t_protocol_handler>
@ -487,7 +493,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
if(!m_is_multithreaded) if(!m_is_multithreaded)
{ {
//single thread model, we can wait in blocked call //single thread model, we can wait in blocked call
size_t cnt = socket().get_io_service().run_one(); size_t cnt = GET_IO_SERVICE(socket()).run_one();
if(!cnt)//service is going to quit if(!cnt)//service is going to quit
return false; return false;
}else }else
@ -497,7 +503,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
//if no handlers were called //if no handlers were called
//TODO: Maybe we need to have have critical section + event + callback to upper protocol to //TODO: Maybe we need to have have critical section + event + callback to upper protocol to
//ask it inside(!) critical region if we still able to go in event wait... //ask it inside(!) critical region if we still able to go in event wait...
size_t cnt = socket().get_io_service().poll_one(); size_t cnt = GET_IO_SERVICE(socket()).poll_one();
if(!cnt) if(!cnt)
misc_utils::sleep_no_w(1); misc_utils::sleep_no_w(1);
} }
@ -1207,7 +1213,7 @@ POP_WARNINGS
template<class t_protocol_handler> template<class t_protocol_handler>
bool boosted_tcp_server<t_protocol_handler>::add_connection(t_connection_context& out, boost::asio::ip::tcp::socket&& sock, network_address real_remote, epee::net_utils::ssl_support_t ssl_support) bool boosted_tcp_server<t_protocol_handler>::add_connection(t_connection_context& out, boost::asio::ip::tcp::socket&& sock, network_address real_remote, epee::net_utils::ssl_support_t ssl_support)
{ {
if(std::addressof(get_io_service()) == std::addressof(sock.get_io_service())) if(std::addressof(get_io_service()) == std::addressof(GET_IO_SERVICE(sock)))
{ {
connection_ptr conn(new connection<t_protocol_handler>(std::move(sock), m_state, m_connection_type, ssl_support, m_ssl_context)); connection_ptr conn(new connection<t_protocol_handler>(std::move(sock), m_state, m_connection_type, ssl_support, m_ssl_context));
if(conn->start(false, 1 < m_threads_count, std::move(real_remote))) if(conn->start(false, 1 < m_threads_count, std::move(real_remote)))

View File

@ -47,6 +47,12 @@
// TODO: // TODO:
#include "net/network_throttle-detail.hpp" #include "net/network_throttle-detail.hpp"
#if BOOST_VERSION >= 107000
#define GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
#else
#define GET_IO_SERVICE(s) ((s).get_io_service())
#endif
#undef MONERO_DEFAULT_LOG_CATEGORY #undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.conn" #define MONERO_DEFAULT_LOG_CATEGORY "net.conn"
@ -117,8 +123,8 @@ connection_basic::connection_basic(boost::asio::ip::tcp::socket&& sock, boost::s
: :
m_stats(std::move(stats)), m_stats(std::move(stats)),
mI( new connection_basic_pimpl("peer") ), mI( new connection_basic_pimpl("peer") ),
strand_(sock.get_io_service()), strand_(GET_IO_SERVICE(sock)),
socket_(sock.get_io_service(), ssl_context.context), socket_(GET_IO_SERVICE(sock), ssl_context.context),
m_want_close_connection(false), m_want_close_connection(false),
m_was_shutdown(false), m_was_shutdown(false),
m_ssl_support(ssl_support), m_ssl_support(ssl_support),