mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Fix gcc warnings and errors
This commit is contained in:
@@ -62,13 +62,13 @@ namespace beast
|
|||||||
#include "tests/beast_TestPeerLogic.h"
|
#include "tests/beast_TestPeerLogic.h"
|
||||||
#include "tests/beast_TestPeerTest.h"
|
#include "tests/beast_TestPeerTest.h"
|
||||||
|
|
||||||
#include "tests/detail/beast_TestPeerType.h"
|
|
||||||
#include "tests/detail/beast_TestPeerTestType.h"
|
|
||||||
#include "tests/detail/beast_TestPeerDetailsTcp.h"
|
|
||||||
#include "tests/detail/beast_TestPeerLogicSyncServer.h"
|
#include "tests/detail/beast_TestPeerLogicSyncServer.h"
|
||||||
#include "tests/detail/beast_TestPeerLogicSyncClient.h"
|
#include "tests/detail/beast_TestPeerLogicSyncClient.h"
|
||||||
#include "tests/detail/beast_TestPeerLogicAsyncServer.h"
|
#include "tests/detail/beast_TestPeerLogicAsyncServer.h"
|
||||||
#include "tests/detail/beast_TestPeerLogicAsyncClient.h"
|
#include "tests/detail/beast_TestPeerLogicAsyncClient.h"
|
||||||
|
#include "tests/detail/beast_TestPeerType.h"
|
||||||
|
#include "tests/detail/beast_TestPeerTestType.h"
|
||||||
|
#include "tests/detail/beast_TestPeerDetailsTcp.h"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public:
|
|||||||
// if Object did not have a declaration for
|
// if Object did not have a declaration for
|
||||||
// protocol_type::socket
|
// protocol_type::socket
|
||||||
//
|
//
|
||||||
template <typename Object, class Enable = void>
|
template <typename AsioObject, class Enable = void>
|
||||||
struct native_socket
|
struct native_socket
|
||||||
{
|
{
|
||||||
typedef void* native_socket_type;
|
typedef void* native_socket_type;
|
||||||
@@ -83,16 +83,15 @@ public:
|
|||||||
native_socket_type m_socket;
|
native_socket_type m_socket;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Object>
|
template <typename AsioObject>
|
||||||
struct native_socket <Object, typename boost::enable_if <boost::is_class <
|
struct native_socket <AsioObject, typename boost::enable_if <boost::is_class <
|
||||||
typename Object::protocol_type::socket> >::type>
|
typename AsioObject::protocol_type::socket> >::type>
|
||||||
{
|
{
|
||||||
typedef typename Object::protocol_type::socket native_socket_type;
|
typedef typename AsioObject::protocol_type::socket native_socket_type;
|
||||||
native_socket (Socket& peer)
|
native_socket (Socket& peer)
|
||||||
: m_socket (&peer.this_layer <native_socket_type> ()) { }
|
: m_socket (&peer.this_layer <native_socket_type> ()) { }
|
||||||
native_socket_type& get () noexcept { return *m_socket; }
|
native_socket_type& get () noexcept { return *m_socket; }
|
||||||
native_socket_type& operator-> () noexcept { return *m_socket; }
|
native_socket_type& operator-> () noexcept { return *m_socket; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
native_socket_type* m_socket;
|
native_socket_type* m_socket;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
timeoutSeconds = 3
|
timeoutSeconds = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
TestPeerTests () : UnitTest ("TestPeer", "beast")
|
TestPeerTests () : UnitTest ("TestPeer", "beast", runManual)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ protected:
|
|||||||
typedef protocol_type::endpoint endpoint_type;
|
typedef protocol_type::endpoint endpoint_type;
|
||||||
typedef protocol_type::resolver resolver_type;
|
typedef protocol_type::resolver resolver_type;
|
||||||
|
|
||||||
struct NoArg { }; // dummy
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef protocol_type arg_type;
|
typedef protocol_type arg_type;
|
||||||
typedef socket_type native_socket_type;
|
typedef socket_type native_socket_type;
|
||||||
|
|||||||
@@ -20,19 +20,49 @@
|
|||||||
#ifndef BEAST_TESTPEERTYPE_H_INCLUDED
|
#ifndef BEAST_TESTPEERTYPE_H_INCLUDED
|
||||||
#define BEAST_TESTPEERTYPE_H_INCLUDED
|
#define BEAST_TESTPEERTYPE_H_INCLUDED
|
||||||
|
|
||||||
template <typename Logic, typename DetailsType>
|
template <typename Logic, typename Details>
|
||||||
class TestPeerType
|
class TestPeerType
|
||||||
: public DetailsType
|
: public Details
|
||||||
, public Logic
|
, public Logic
|
||||||
, public TestPeer
|
, public TestPeer
|
||||||
, public Thread
|
, public Thread
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
// TestPeerDetails
|
||||||
|
using Details::get_socket;
|
||||||
|
using Details::get_acceptor;
|
||||||
|
using Details::get_io_service;
|
||||||
|
|
||||||
|
// Details
|
||||||
|
typedef typename Details::protocol_type protocol_type;
|
||||||
|
typedef typename Details::socket_type socket_type;
|
||||||
|
typedef typename Details::acceptor_type acceptor_type;
|
||||||
|
typedef typename Details::endpoint_type endpoint_type;
|
||||||
|
typedef typename Details::resolver_type resolver_type;
|
||||||
|
|
||||||
|
using Details::get_native_socket;
|
||||||
|
using Details::get_native_acceptor;
|
||||||
|
using Details::get_endpoint;
|
||||||
|
|
||||||
|
// TestPeerLogic
|
||||||
|
using Logic::error;
|
||||||
|
using Logic::socket;
|
||||||
|
using Logic::get_role;
|
||||||
|
using Logic::get_model;
|
||||||
|
using Logic::on_connect;
|
||||||
|
using Logic::on_connect_async;
|
||||||
|
using Logic::pure_virtual;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename DetailsType::arg_type arg_type;
|
// Details
|
||||||
typedef TestPeerType <Logic, DetailsType> ThisType;
|
typedef typename Details::arg_type arg_type;
|
||||||
|
typedef typename Details::native_socket_type native_socket_type;
|
||||||
|
typedef typename Details::native_acceptor_type native_acceptor_type;
|
||||||
|
|
||||||
|
typedef TestPeerType <Logic, Details> ThisType;
|
||||||
|
|
||||||
TestPeerType (arg_type const& arg)
|
TestPeerType (arg_type const& arg)
|
||||||
: DetailsType (arg)
|
: Details (arg)
|
||||||
, Logic (get_socket ())
|
, Logic (get_socket ())
|
||||||
, Thread (name ())
|
, Thread (name ())
|
||||||
{
|
{
|
||||||
@@ -162,13 +192,17 @@ public:
|
|||||||
if (failure (get_native_acceptor ().open (get_endpoint (get_role ()).protocol (), error ())))
|
if (failure (get_native_acceptor ().open (get_endpoint (get_role ()).protocol (), error ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (failure (get_native_acceptor ().set_option (socket_type::reuse_address (true), error ())))
|
// VFALCO TODO Figure out how to not hard code boost::asio::socket_base
|
||||||
|
if (failure (get_native_acceptor ().set_option (
|
||||||
|
boost::asio::socket_base::reuse_address (true), error ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (failure (get_native_acceptor ().bind (get_endpoint (get_role ()), error ())))
|
if (failure (get_native_acceptor ().bind (get_endpoint (get_role ()), error ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (failure (get_native_acceptor ().listen (socket_type::max_connections, error ())))
|
// VFALCO TODO Figure out how to not hard code boost::asio::socket_base
|
||||||
|
if (failure (get_native_acceptor ().listen (
|
||||||
|
boost::asio::socket_base::max_connections, error ())))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ MultiSocket* MultiSocket::New (boost::asio::io_service& io_service,
|
|||||||
class MultiSocketTests : public UnitTest
|
class MultiSocketTests : public UnitTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class Details : public TestPeerDetails
|
class MultiSocketDetails : public TestPeerDetails
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef int arg_type;
|
typedef int arg_type;
|
||||||
@@ -54,7 +54,7 @@ public:
|
|||||||
tcpv6 = 32
|
tcpv6 = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
Details (arg_type flags)
|
MultiSocketDetails (arg_type flags)
|
||||||
: m_flags (flags)
|
: m_flags (flags)
|
||||||
{
|
{
|
||||||
m_socketOptions.useClientSsl = (flags & client_ssl) != 0;
|
m_socketOptions.useClientSsl = (flags & client_ssl) != 0;
|
||||||
@@ -66,6 +66,8 @@ public:
|
|||||||
static String getArgName (arg_type arg)
|
static String getArgName (arg_type arg)
|
||||||
{
|
{
|
||||||
String s;
|
String s;
|
||||||
|
if (arg & tcpv4) s << "tcpv4:";
|
||||||
|
if (arg & tcpv6) s << "tcpv6:";
|
||||||
if (arg != 0)
|
if (arg != 0)
|
||||||
{
|
{
|
||||||
s << "[";
|
s << "[";
|
||||||
@@ -73,8 +75,6 @@ public:
|
|||||||
if (arg & server_ssl) s << "server_ssl,";
|
if (arg & server_ssl) s << "server_ssl,";
|
||||||
if (arg & server_ssl_required) s << "server_ssl_required,";
|
if (arg & server_ssl_required) s << "server_ssl_required,";
|
||||||
if (arg & server_proxy) s << "server_proxy,";
|
if (arg & server_proxy) s << "server_proxy,";
|
||||||
if (arg & tcpv4) s << "tcpv4,";
|
|
||||||
if (arg & tcpv6) s << "tcpv6,";
|
|
||||||
s = s.substring (0, s.length () - 1) + "]";
|
s = s.substring (0, s.length () - 1) + "]";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -104,8 +104,10 @@ public:
|
|||||||
MultiSocket::Options m_socketOptions;
|
MultiSocket::Options m_socketOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
template <class InternetProtocol>
|
template <class InternetProtocol>
|
||||||
class DetailsType : public Details
|
class MultiSocketDetailsType : public MultiSocketDetails
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef InternetProtocol protocol_type;
|
typedef InternetProtocol protocol_type;
|
||||||
@@ -118,8 +120,8 @@ public:
|
|||||||
typedef socket_type native_socket_type;
|
typedef socket_type native_socket_type;
|
||||||
typedef acceptor_type native_acceptor_type;
|
typedef acceptor_type native_acceptor_type;
|
||||||
|
|
||||||
explicit DetailsType (arg_type flags = none)
|
explicit MultiSocketDetailsType (arg_type flags = none)
|
||||||
: Details (flags)
|
: MultiSocketDetails (flags)
|
||||||
, m_socket (get_io_service ())
|
, m_socket (get_io_service ())
|
||||||
, m_acceptor (get_io_service ())
|
, m_acceptor (get_io_service ())
|
||||||
, m_multiSocket (m_socket, getSocketOptions ())
|
, m_multiSocket (m_socket, getSocketOptions ())
|
||||||
@@ -149,24 +151,20 @@ public:
|
|||||||
|
|
||||||
endpoint_type get_endpoint (TestPeer::Role role)
|
endpoint_type get_endpoint (TestPeer::Role role)
|
||||||
{
|
{
|
||||||
if (getFlags () & Details::tcpv4)
|
if (getFlags () & MultiSocketDetails::tcpv6)
|
||||||
{
|
|
||||||
if (role == TestPeer::Role::server)
|
|
||||||
{
|
|
||||||
return endpoint_type (boost::asio::ip::address_v4::any (), 1053);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return endpoint_type (boost::asio::ip::address_v4::loopback (), 1053);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (role == TestPeer::Role::server)
|
if (role == TestPeer::Role::server)
|
||||||
return endpoint_type (boost::asio::ip::tcp::v6 (), 1052);
|
return endpoint_type (boost::asio::ip::tcp::v6 (), 1052);
|
||||||
else
|
else
|
||||||
return endpoint_type (boost::asio::ip::address_v6 ().from_string ("::1"), 1052);
|
return endpoint_type (boost::asio::ip::address_v6 ().from_string ("::1"), 1052);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (role == TestPeer::Role::server)
|
||||||
|
return endpoint_type (boost::asio::ip::address_v4::any (), 1053);
|
||||||
|
else
|
||||||
|
return endpoint_type (boost::asio::ip::address_v4::loopback (), 1053);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -176,7 +174,7 @@ public:
|
|||||||
SocketWrapper <acceptor_type> m_acceptor_wrapper;
|
SocketWrapper <acceptor_type> m_acceptor_wrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
MultiSocketTests () : UnitTest ("MultiSocket", "ripple")
|
MultiSocketTests () : UnitTest ("MultiSocket", "ripple", runManual)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +193,7 @@ public:
|
|||||||
template <typename InternetProtocol, class Arg>
|
template <typename InternetProtocol, class Arg>
|
||||||
void testProtocol (Arg const& arg)
|
void testProtocol (Arg const& arg)
|
||||||
{
|
{
|
||||||
testAsync <DetailsType <InternetProtocol> > (arg);
|
testAsync <MultiSocketDetailsType <InternetProtocol> > (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testOptions (int flags)
|
void testOptions (int flags)
|
||||||
@@ -208,14 +206,14 @@ public:
|
|||||||
void runTest ()
|
void runTest ()
|
||||||
{
|
{
|
||||||
// These should pass
|
// These should pass
|
||||||
testOptions (Details::none);
|
testOptions (MultiSocketDetails::none);
|
||||||
testOptions (Details::server_ssl);
|
testOptions (MultiSocketDetails::server_ssl);
|
||||||
testOptions (Details::client_ssl | Details::server_ssl);
|
testOptions (MultiSocketDetails::client_ssl | MultiSocketDetails::server_ssl);
|
||||||
testOptions (Details::client_ssl | Details::server_ssl_required);
|
testOptions (MultiSocketDetails::client_ssl | MultiSocketDetails::server_ssl_required);
|
||||||
|
|
||||||
// These should fail
|
// These should fail
|
||||||
testOptions (Details::client_ssl);
|
testOptions (MultiSocketDetails::client_ssl);
|
||||||
testOptions (Details::server_ssl_required);
|
testOptions (MultiSocketDetails::server_ssl_required);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,11 @@ public:
|
|||||||
boost::asio::ssl::context& context,
|
boost::asio::ssl::context& context,
|
||||||
Handler& handler)
|
Handler& handler)
|
||||||
: m_handler (handler)
|
: m_handler (handler)
|
||||||
, mSocket (io_service, context)
|
|
||||||
, mStrand (io_service)
|
, mStrand (io_service)
|
||||||
|
, mSocket (io_service, context)
|
||||||
#if RIPPLE_USES_BEAST_SOCKETS
|
#if RIPPLE_USES_BEAST_SOCKETS
|
||||||
, m_socketWrapper (mSocket)
|
, m_socketWrapper (mSocket)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,11 +257,11 @@ private:
|
|||||||
private:
|
private:
|
||||||
Handler& m_handler;
|
Handler& m_handler;
|
||||||
|
|
||||||
|
boost::asio::io_service::strand mStrand;
|
||||||
AutoSocket mSocket;
|
AutoSocket mSocket;
|
||||||
#if RIPPLE_USES_BEAST_SOCKETS
|
#if RIPPLE_USES_BEAST_SOCKETS
|
||||||
SocketWrapper <AutoSocket> m_socketWrapper;
|
SocketWrapper <AutoSocket> m_socketWrapper;
|
||||||
#endif
|
#endif
|
||||||
boost::asio::io_service::strand mStrand;
|
|
||||||
|
|
||||||
boost::asio::streambuf mLineBuffer;
|
boost::asio::streambuf mLineBuffer;
|
||||||
Blob mQueryVec;
|
Blob mQueryVec;
|
||||||
|
|||||||
Reference in New Issue
Block a user