mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Fixes to handshake and socket wrapper
This commit is contained in:
@@ -146,15 +146,18 @@ public:
|
||||
{
|
||||
#if BEAST_ASIO_HAS_FUTURE_RETURNS
|
||||
boost::asio::detail::async_result_init<
|
||||
ErrorCall, void (error_code)> init(
|
||||
HandshakeHandler, void (error_code)> init(
|
||||
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
|
||||
// init.handler is copied
|
||||
m_origHandler = ErrorCall (HandshakeHandler(init.handler));
|
||||
m_origHandler = ErrorCall (
|
||||
BOOST_ASIO_MOVE_CAST(HandshakeHandler)
|
||||
(HandshakeHandler(init.handler)));
|
||||
bassert (m_origBufferedHandler.isNull ());
|
||||
async_do_handshake (type, ConstBuffers ());
|
||||
return init.result.get();
|
||||
#else
|
||||
m_origHandler = ErrorCall (handler);
|
||||
m_origHandler = ErrorCall (
|
||||
BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
|
||||
bassert (m_origBufferedHandler.isNull ());
|
||||
async_do_handshake (type, ConstBuffers ());
|
||||
#endif
|
||||
@@ -165,7 +168,7 @@ public:
|
||||
error_code handshake (handshake_type type,
|
||||
const ConstBufferSequence& buffers, error_code& ec)
|
||||
{
|
||||
return do_handshake (type, ec, ConstBuffers (buffers));;
|
||||
return do_handshake (type, ec, ConstBuffers (buffers));
|
||||
}
|
||||
|
||||
template <typename ConstBufferSequence, typename BufferedHandshakeHandler>
|
||||
@@ -178,12 +181,15 @@ public:
|
||||
BufferedHandshakeHandler, void (error_code, std::size_t)> init(
|
||||
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)(handler));
|
||||
// init.handler is copied
|
||||
m_origBufferedHandler = TransferCall (BufferedHandshakeHandler(init.handler));
|
||||
m_origBufferedHandler = TransferCall (
|
||||
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler)
|
||||
(BufferedHandshakeHandler(init.handler)));
|
||||
bassert (m_origHandler.isNull ());
|
||||
async_do_handshake (type, ConstBuffers (buffers));
|
||||
return init.result.get();
|
||||
#else
|
||||
m_origBufferedHandler = TransferCall (handler);
|
||||
m_origBufferedHandler = TransferCall (
|
||||
BOOST_ASIO_MOVE_CAST(BufferedHandshakeHandler(handler)));
|
||||
bassert (m_origHandler.isNull ());
|
||||
async_do_handshake (type, ConstBuffers (buffers));
|
||||
#endif
|
||||
@@ -240,6 +246,8 @@ public:
|
||||
void async_do_handshake (handshake_type type, ConstBuffers const& buffers)
|
||||
{
|
||||
// Transfer caller data to our buffer.
|
||||
// We commit the bytes in on_async_read_some.
|
||||
//
|
||||
std::size_t const bytes_transferred (boost::asio::buffer_copy (
|
||||
m_buffer.prepare (boost::asio::buffer_size (buffers)), buffers));
|
||||
|
||||
@@ -275,6 +283,7 @@ public:
|
||||
// continuation?
|
||||
m_callback->on_async_detect (m_logic.get (), ec,
|
||||
ConstBuffers (m_buffer.data ()), m_origBufferedHandler);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -283,6 +292,7 @@ public:
|
||||
// continuation?
|
||||
m_callback->on_async_detect (m_logic.get (), ec,
|
||||
ConstBuffers (m_buffer.data ()), m_origHandler);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ Socket::async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(TransferCall)
|
||||
// ssl::stream
|
||||
//
|
||||
|
||||
bool Socket::requires_handshake ()
|
||||
bool Socket::needs_handshake ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public:
|
||||
|
||||
/** Determines if the underlying stream requires a handshake.
|
||||
|
||||
If requires_handshake is true, it will be necessary to call handshake or
|
||||
If needs_handshake is true, it will be necessary to call handshake or
|
||||
async_handshake after the connection is established. Furthermore it
|
||||
will be necessary to call the shutdown member from the
|
||||
HandshakeInterface to close the connection. Do not close the underlying
|
||||
@@ -250,7 +250,7 @@ public:
|
||||
|
||||
The default version returns false.
|
||||
*/
|
||||
virtual bool requires_handshake ();
|
||||
virtual bool needs_handshake ();
|
||||
|
||||
// ssl::stream::handshake (1 of 4)
|
||||
// http://www.boost.org/doc/libs/1_54_0/doc/html/boost_asio/reference/ssl__stream/handshake/overload1.html
|
||||
|
||||
@@ -549,7 +549,7 @@ public:
|
||||
// ssl::stream
|
||||
//
|
||||
|
||||
bool requires_handshake ()
|
||||
bool needs_handshake ()
|
||||
{
|
||||
using namespace SocketWrapperMemberChecks;
|
||||
return
|
||||
|
||||
@@ -37,7 +37,7 @@ void TestPeerLogicAsyncClient::on_connect_async (error_code const& ec)
|
||||
if (aborted (ec) || failure (error (ec)))
|
||||
return finished ();
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().async_handshake (Socket::client,
|
||||
boost::bind (&TestPeerLogicAsyncClient::on_handshake, this,
|
||||
@@ -99,7 +99,7 @@ void TestPeerLogicAsyncClient::on_read_final (error_code const& ec, std::size_t)
|
||||
//
|
||||
if (ec == boost::asio::error::eof)
|
||||
{
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().async_shutdown (boost::bind (&TestPeerLogicAsyncClient::on_shutdown, this,
|
||||
boost::asio::placeholders::error));
|
||||
@@ -135,7 +135,7 @@ void TestPeerLogicAsyncClient::on_shutdown (error_code const& ec)
|
||||
{
|
||||
if (success (error (ec), true))
|
||||
{
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().shutdown (Socket::shutdown_both, error ());
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void TestPeerLogicAsyncServer::on_connect_async (error_code const& ec)
|
||||
if (aborted (ec) || failure (error (ec)))
|
||||
return finished ();
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().async_handshake (Socket::server,
|
||||
boost::bind (&TestPeerLogicAsyncServer::on_handshake, this,
|
||||
@@ -80,7 +80,7 @@ void TestPeerLogicAsyncServer::on_write (error_code const& ec, std::size_t bytes
|
||||
if (unexpected (bytes_transferred == 7, error ()))
|
||||
return finished ();
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().async_shutdown (boost::bind (&TestPeerLogicAsyncServer::on_shutdown, this,
|
||||
boost::asio::placeholders::error));
|
||||
@@ -100,7 +100,7 @@ void TestPeerLogicAsyncServer::on_shutdown (error_code const& ec)
|
||||
{
|
||||
if (success (error (ec), true))
|
||||
{
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
socket ().shutdown (Socket::shutdown_both, error ());
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void TestPeerLogicSyncClient::on_connect ()
|
||||
return ;
|
||||
}
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
if (failure (socket ().handshake (to_handshake_type (get_role ()), error ())))
|
||||
return;
|
||||
@@ -90,7 +90,7 @@ void TestPeerLogicSyncClient::on_connect ()
|
||||
}
|
||||
}
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
if (failure (socket ().shutdown (error ()), true))
|
||||
return;
|
||||
|
||||
@@ -34,7 +34,7 @@ TestPeerBasics::Model TestPeerLogicSyncServer::get_model () const noexcept
|
||||
|
||||
void TestPeerLogicSyncServer::on_connect ()
|
||||
{
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
if (failure (socket ().handshake (to_handshake_type (get_role ()), error ())))
|
||||
return;
|
||||
@@ -66,7 +66,7 @@ void TestPeerLogicSyncServer::on_connect ()
|
||||
return;
|
||||
}
|
||||
|
||||
if (socket ().requires_handshake ())
|
||||
if (socket ().needs_handshake ())
|
||||
{
|
||||
if (failure (socket ().shutdown (error ()), true))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user