updated boost on windows
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/buffered_handshake_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -28,8 +26,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
template <typename ConstBufferSequence>
|
||||
class buffered_handshake_op
|
||||
{
|
||||
@@ -46,8 +42,27 @@ public:
|
||||
boost::system::error_code& ec,
|
||||
std::size_t& bytes_transferred) const
|
||||
{
|
||||
typename ConstBufferSequence::const_iterator iter = buffers_.begin();
|
||||
typename ConstBufferSequence::const_iterator end = buffers_.end();
|
||||
return this->process(eng, ec, bytes_transferred,
|
||||
boost::asio::buffer_sequence_begin(buffers_),
|
||||
boost::asio::buffer_sequence_end(buffers_));
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
void call_handler(Handler& handler,
|
||||
const boost::system::error_code& ec,
|
||||
const std::size_t& bytes_transferred) const
|
||||
{
|
||||
handler(ec, bytes_transferred);
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename Iterator>
|
||||
engine::want process(engine& eng,
|
||||
boost::system::error_code& ec,
|
||||
std::size_t& bytes_transferred,
|
||||
Iterator begin, Iterator end) const
|
||||
{
|
||||
Iterator iter = begin;
|
||||
std::size_t accumulated_size = 0;
|
||||
|
||||
for (;;)
|
||||
@@ -63,9 +78,9 @@ public:
|
||||
const_buffer buffer(*iter);
|
||||
|
||||
// Skip over any buffers which have already been consumed by the engine.
|
||||
if (bytes_transferred >= accumulated_size + buffer_size(buffer))
|
||||
if (bytes_transferred >= accumulated_size + buffer.size())
|
||||
{
|
||||
accumulated_size += buffer_size(buffer);
|
||||
accumulated_size += buffer.size();
|
||||
++iter;
|
||||
continue;
|
||||
}
|
||||
@@ -78,30 +93,19 @@ public:
|
||||
|
||||
// Pass the buffer to the engine, and update the bytes transferred to
|
||||
// reflect the total number of bytes consumed so far.
|
||||
bytes_transferred += buffer_size(buffer);
|
||||
bytes_transferred += buffer.size();
|
||||
buffer = eng.put_input(buffer);
|
||||
bytes_transferred -= buffer_size(buffer);
|
||||
bytes_transferred -= buffer.size();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Handler>
|
||||
void call_handler(Handler& handler,
|
||||
const boost::system::error_code& ec,
|
||||
const std::size_t& bytes_transferred) const
|
||||
{
|
||||
handler(ec, bytes_transferred);
|
||||
}
|
||||
|
||||
private:
|
||||
stream_base::handshake_type type_;
|
||||
ConstBufferSequence buffers_;
|
||||
std::size_t total_buffer_size_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/engine.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,14 +17,12 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/buffer.hpp>
|
||||
# include <boost/asio/detail/static_mutex.hpp>
|
||||
# include <boost/asio/ssl/detail/openssl_types.hpp>
|
||||
# include <boost/asio/ssl/detail/verify_callback.hpp>
|
||||
# include <boost/asio/ssl/stream_base.hpp>
|
||||
# include <boost/asio/ssl/verify_mode.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/asio/detail/static_mutex.hpp>
|
||||
#include <boost/asio/ssl/detail/openssl_types.hpp>
|
||||
#include <boost/asio/ssl/detail/verify_callback.hpp>
|
||||
#include <boost/asio/ssl/stream_base.hpp>
|
||||
#include <boost/asio/ssl/verify_mode.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -33,8 +31,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
class engine
|
||||
{
|
||||
public:
|
||||
@@ -98,7 +94,7 @@ public:
|
||||
boost::system::error_code& ec, std::size_t& bytes_transferred);
|
||||
|
||||
// Get output data to be written to the transport.
|
||||
BOOST_ASIO_DECL boost::asio::mutable_buffers_1 get_output(
|
||||
BOOST_ASIO_DECL boost::asio::mutable_buffer get_output(
|
||||
const boost::asio::mutable_buffer& data);
|
||||
|
||||
// Put input data that was read from the transport.
|
||||
@@ -120,9 +116,11 @@ private:
|
||||
BOOST_ASIO_DECL static int verify_callback_function(
|
||||
int preverified, X509_STORE_CTX* ctx);
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
// The SSL_accept function may not be thread safe. This mutex is used to
|
||||
// protect all calls to the SSL_accept function.
|
||||
BOOST_ASIO_DECL static boost::asio::detail::static_mutex& accept_mutex();
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
|
||||
// Perform one operation. Returns >= 0 on success or error, want_read if the
|
||||
// operation needs more input, or want_write if it needs to write some output
|
||||
@@ -150,8 +148,6 @@ private:
|
||||
BIO* ext_bio_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/handshake_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -28,8 +26,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
class handshake_op
|
||||
{
|
||||
public:
|
||||
@@ -58,8 +54,6 @@ private:
|
||||
stream_base::handshake_type type_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/impl/engine.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,13 +17,11 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/detail/throw_error.hpp>
|
||||
# include <boost/asio/error.hpp>
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
# include <boost/asio/ssl/error.hpp>
|
||||
# include <boost/asio/ssl/verify_context.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
#include <boost/asio/ssl/error.hpp>
|
||||
#include <boost/asio/ssl/verify_context.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -32,8 +30,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
engine::engine(SSL_CTX* context)
|
||||
: ssl_(::SSL_new(context))
|
||||
{
|
||||
@@ -45,7 +41,9 @@ engine::engine(SSL_CTX* context)
|
||||
boost::asio::detail::throw_error(ec, "engine");
|
||||
}
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
accept_mutex().init();
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
|
||||
::SSL_set_mode(ssl_, SSL_MODE_ENABLE_PARTIAL_WRITE);
|
||||
::SSL_set_mode(ssl_, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
|
||||
@@ -146,37 +144,35 @@ engine::want engine::shutdown(boost::system::error_code& ec)
|
||||
engine::want engine::write(const boost::asio::const_buffer& data,
|
||||
boost::system::error_code& ec, std::size_t& bytes_transferred)
|
||||
{
|
||||
if (boost::asio::buffer_size(data) == 0)
|
||||
if (data.size() == 0)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
return engine::want_nothing;
|
||||
}
|
||||
|
||||
return perform(&engine::do_write,
|
||||
const_cast<void*>(boost::asio::buffer_cast<const void*>(data)),
|
||||
boost::asio::buffer_size(data), ec, &bytes_transferred);
|
||||
const_cast<void*>(data.data()),
|
||||
data.size(), ec, &bytes_transferred);
|
||||
}
|
||||
|
||||
engine::want engine::read(const boost::asio::mutable_buffer& data,
|
||||
boost::system::error_code& ec, std::size_t& bytes_transferred)
|
||||
{
|
||||
if (boost::asio::buffer_size(data) == 0)
|
||||
if (data.size() == 0)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
return engine::want_nothing;
|
||||
}
|
||||
|
||||
return perform(&engine::do_read,
|
||||
boost::asio::buffer_cast<void*>(data),
|
||||
boost::asio::buffer_size(data), ec, &bytes_transferred);
|
||||
return perform(&engine::do_read, data.data(),
|
||||
data.size(), ec, &bytes_transferred);
|
||||
}
|
||||
|
||||
boost::asio::mutable_buffers_1 engine::get_output(
|
||||
boost::asio::mutable_buffer engine::get_output(
|
||||
const boost::asio::mutable_buffer& data)
|
||||
{
|
||||
int length = ::BIO_read(ext_bio_,
|
||||
boost::asio::buffer_cast<void*>(data),
|
||||
static_cast<int>(boost::asio::buffer_size(data)));
|
||||
data.data(), static_cast<int>(data.size()));
|
||||
|
||||
return boost::asio::buffer(data,
|
||||
length > 0 ? static_cast<std::size_t>(length) : 0);
|
||||
@@ -186,8 +182,7 @@ boost::asio::const_buffer engine::put_input(
|
||||
const boost::asio::const_buffer& data)
|
||||
{
|
||||
int length = ::BIO_write(ext_bio_,
|
||||
boost::asio::buffer_cast<const void*>(data),
|
||||
static_cast<int>(boost::asio::buffer_size(data)));
|
||||
data.data(), static_cast<int>(data.size()));
|
||||
|
||||
return boost::asio::buffer(data +
|
||||
(length > 0 ? static_cast<std::size_t>(length) : 0));
|
||||
@@ -210,7 +205,7 @@ const boost::system::error_code& engine::map_error_code(
|
||||
// SSL v2 doesn't provide a protocol-level shutdown, so an eof on the
|
||||
// underlying transport is passed through.
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
if (ssl_->version == SSL2_VERSION)
|
||||
if (SSL_version(ssl_) == SSL2_VERSION)
|
||||
return ec;
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
|
||||
@@ -223,11 +218,13 @@ const boost::system::error_code& engine::map_error_code(
|
||||
return ec;
|
||||
}
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
boost::asio::detail::static_mutex& engine::accept_mutex()
|
||||
{
|
||||
static boost::asio::detail::static_mutex mutex = BOOST_ASIO_STATIC_MUTEX_INIT;
|
||||
return mutex;
|
||||
}
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
|
||||
engine::want engine::perform(int (engine::* op)(void*, std::size_t),
|
||||
void* data, std::size_t length, boost::system::error_code& ec,
|
||||
@@ -244,14 +241,23 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
|
||||
{
|
||||
ec = boost::system::error_code(sys_error,
|
||||
boost::asio::error::get_ssl_category());
|
||||
return want_nothing;
|
||||
return pending_output_after > pending_output_before
|
||||
? want_output : want_nothing;
|
||||
}
|
||||
|
||||
if (ssl_error == SSL_ERROR_SYSCALL)
|
||||
{
|
||||
ec = boost::system::error_code(sys_error,
|
||||
boost::asio::error::get_system_category());
|
||||
return want_nothing;
|
||||
if (sys_error == 0)
|
||||
{
|
||||
ec = boost::asio::ssl::error::unspecified_system_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = boost::system::error_code(sys_error,
|
||||
boost::asio::error::get_ssl_category());
|
||||
}
|
||||
return pending_output_after > pending_output_before
|
||||
? want_output : want_nothing;
|
||||
}
|
||||
|
||||
if (result > 0 && bytes_transferred)
|
||||
@@ -272,21 +278,28 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
|
||||
ec = boost::system::error_code();
|
||||
return want_input_and_retry;
|
||||
}
|
||||
else if (::SSL_get_shutdown(ssl_) & SSL_RECEIVED_SHUTDOWN)
|
||||
else if (ssl_error == SSL_ERROR_ZERO_RETURN)
|
||||
{
|
||||
ec = boost::asio::error::eof;
|
||||
return want_nothing;
|
||||
}
|
||||
else
|
||||
else if (ssl_error == SSL_ERROR_NONE)
|
||||
{
|
||||
ec = boost::system::error_code();
|
||||
return want_nothing;
|
||||
}
|
||||
else
|
||||
{
|
||||
ec = boost::asio::ssl::error::unexpected_result;
|
||||
return want_nothing;
|
||||
}
|
||||
}
|
||||
|
||||
int engine::do_accept(void*, std::size_t)
|
||||
{
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
boost::asio::detail::static_mutex::scoped_lock lock(accept_mutex());
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
return ::SSL_accept(ssl_);
|
||||
}
|
||||
|
||||
@@ -315,8 +328,6 @@ int engine::do_write(void* data, std::size_t length)
|
||||
length < INT_MAX ? static_cast<int>(length) : INT_MAX);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
|
||||
// Copyright (c) 2005-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2005-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -79,12 +79,13 @@ public:
|
||||
#elif (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
::ERR_remove_thread_state(NULL);
|
||||
#endif // (OPENSSL_VERSION_NUMBER < 0x10000000L)
|
||||
#if !defined(SSL_OP_NO_COMPRESSION) \
|
||||
&& (OPENSSL_VERSION_NUMBER >= 0x10002000L) \
|
||||
&& (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x10002000L) \
|
||||
&& (OPENSSL_VERSION_NUMBER < 0x10100000L) \
|
||||
&& !defined(SSL_OP_NO_COMPRESSION)
|
||||
::SSL_COMP_free_compression_methods();
|
||||
#endif // (OPENSSL_VERSION_NUMBER >= 0x10002000L)
|
||||
// && (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
// && !defined(SSL_OP_NO_COMPRESSION)
|
||||
#if !defined(OPENSSL_IS_BORINGSSL)
|
||||
::CONF_modules_unload(1);
|
||||
#endif // !defined(OPENSSL_IS_BORINGSSL)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/io.hpp
|
||||
// ~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,11 +17,9 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
# include <boost/asio/ssl/detail/stream_core.hpp>
|
||||
# include <boost/asio/write.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
#include <boost/asio/ssl/detail/stream_core.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -30,12 +28,11 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
std::size_t io(Stream& next_layer, stream_core& core,
|
||||
const Operation& op, boost::system::error_code& ec)
|
||||
{
|
||||
boost::system::error_code io_ec;
|
||||
std::size_t bytes_transferred = 0;
|
||||
do switch (op(core.engine_, ec, bytes_transferred))
|
||||
{
|
||||
@@ -43,9 +40,13 @@ std::size_t io(Stream& next_layer, stream_core& core,
|
||||
|
||||
// If the input buffer is empty then we need to read some more data from
|
||||
// the underlying transport.
|
||||
if (boost::asio::buffer_size(core.input_) == 0)
|
||||
if (core.input_.size() == 0)
|
||||
{
|
||||
core.input_ = boost::asio::buffer(core.input_buffer_,
|
||||
next_layer.read_some(core.input_buffer_, ec));
|
||||
next_layer.read_some(core.input_buffer_, io_ec));
|
||||
if (!ec)
|
||||
ec = io_ec;
|
||||
}
|
||||
|
||||
// Pass the new input data to the engine.
|
||||
core.input_ = core.engine_.put_input(core.input_);
|
||||
@@ -58,7 +59,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
|
||||
// Get output data from the engine and write it to the underlying
|
||||
// transport.
|
||||
boost::asio::write(next_layer,
|
||||
core.engine_.get_output(core.output_buffer_), ec);
|
||||
core.engine_.get_output(core.output_buffer_), io_ec);
|
||||
if (!ec)
|
||||
ec = io_ec;
|
||||
|
||||
// Try the operation again.
|
||||
continue;
|
||||
@@ -68,7 +71,9 @@ std::size_t io(Stream& next_layer, stream_core& core,
|
||||
// Get output data from the engine and write it to the underlying
|
||||
// transport.
|
||||
boost::asio::write(next_layer,
|
||||
core.engine_.get_output(core.output_buffer_), ec);
|
||||
core.engine_.get_output(core.output_buffer_), io_ec);
|
||||
if (!ec)
|
||||
ec = io_ec;
|
||||
|
||||
// Operation is complete. Return result to caller.
|
||||
core.engine_.map_error_code(ec);
|
||||
@@ -119,7 +124,7 @@ public:
|
||||
io_op(io_op&& other)
|
||||
: next_layer_(other.next_layer_),
|
||||
core_(other.core_),
|
||||
op_(other.op_),
|
||||
op_(BOOST_ASIO_MOVE_CAST(Operation)(other.op_)),
|
||||
start_(other.start_),
|
||||
want_(other.want_),
|
||||
ec_(other.ec_),
|
||||
@@ -143,7 +148,7 @@ public:
|
||||
|
||||
// If the input buffer already has data in it we can pass it to the
|
||||
// engine and then retry the operation immediately.
|
||||
if (boost::asio::buffer_size(core_.input_) != 0)
|
||||
if (core_.input_.size() != 0)
|
||||
{
|
||||
core_.input_ = core_.engine_.put_input(core_.input_);
|
||||
continue;
|
||||
@@ -153,7 +158,7 @@ public:
|
||||
// cannot allow more than one read operation at a time on the
|
||||
// underlying transport. The pending_read_ timer's expiry is set to
|
||||
// pos_infin if a read is in progress, and neg_infin otherwise.
|
||||
if (core_.pending_read_.expires_at() == core_.neg_infin())
|
||||
if (core_.expiry(core_.pending_read_) == core_.neg_infin())
|
||||
{
|
||||
// Prevent other read operations from being started.
|
||||
core_.pending_read_.expires_at(core_.pos_infin());
|
||||
@@ -180,7 +185,7 @@ public:
|
||||
// cannot allow more than one write operation at a time on the
|
||||
// underlying transport. The pending_write_ timer's expiry is set to
|
||||
// pos_infin if a write is in progress, and neg_infin otherwise.
|
||||
if (core_.pending_write_.expires_at() == core_.neg_infin())
|
||||
if (core_.expiry(core_.pending_write_) == core_.neg_infin())
|
||||
{
|
||||
// Prevent other write operations from being started.
|
||||
core_.pending_write_.expires_at(core_.pos_infin());
|
||||
@@ -206,7 +211,7 @@ public:
|
||||
// have to keep in mind that this function might be being called from
|
||||
// the async operation's initiating function. In this case we're not
|
||||
// allowed to call the handler directly. Instead, issue a zero-sized
|
||||
// read so the handler runs "as-if" posted using io_service::post().
|
||||
// read so the handler runs "as-if" posted using io_context::post().
|
||||
if (start)
|
||||
{
|
||||
next_layer_.async_read_some(
|
||||
@@ -288,7 +293,7 @@ public:
|
||||
Handler handler_;
|
||||
};
|
||||
|
||||
template <typename Stream, typename Operation, typename Handler>
|
||||
template <typename Stream, typename Operation, typename Handler>
|
||||
inline void* asio_handler_allocate(std::size_t size,
|
||||
io_op<Stream, Operation, Handler>* this_handler)
|
||||
{
|
||||
@@ -339,10 +344,37 @@ inline void async_io(Stream& next_layer, stream_core& core,
|
||||
boost::system::error_code(), 0, 1);
|
||||
}
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
|
||||
template <typename Stream, typename Operation,
|
||||
typename Handler, typename Allocator>
|
||||
struct associated_allocator<
|
||||
ssl::detail::io_op<Stream, Operation, Handler>, Allocator>
|
||||
{
|
||||
typedef typename associated_allocator<Handler, Allocator>::type type;
|
||||
|
||||
static type get(const ssl::detail::io_op<Stream, Operation, Handler>& h,
|
||||
const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_allocator<Handler, Allocator>::get(h.handler_, a);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename Operation,
|
||||
typename Handler, typename Executor>
|
||||
struct associated_executor<
|
||||
ssl::detail::io_op<Stream, Operation, Handler>, Executor>
|
||||
{
|
||||
typedef typename associated_executor<Handler, Executor>::type type;
|
||||
|
||||
static type get(const ssl::detail::io_op<Stream, Operation, Handler>& h,
|
||||
const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return associated_executor<Handler, Executor>::get(h.handler_, ex);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/openssl_init.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstring>
|
||||
#include <boost/asio/detail/memory.hpp>
|
||||
#include <boost/asio/detail/noncopyable.hpp>
|
||||
#include <boost/asio/detail/shared_ptr.hpp>
|
||||
#include <boost/asio/ssl/detail/openssl_types.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/openssl_types.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/password_callback.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,11 +17,9 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <cstddef>
|
||||
# include <string>
|
||||
# include <boost/asio/ssl/context_base.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <boost/asio/ssl/context_base.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -30,8 +28,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
class password_callback_base
|
||||
{
|
||||
public:
|
||||
@@ -62,8 +58,6 @@ private:
|
||||
PasswordCallback callback_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/read_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/detail/buffer_sequence_adapter.hpp>
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/detail/buffer_sequence_adapter.hpp>
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -29,8 +27,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
template <typename MutableBufferSequence>
|
||||
class read_op
|
||||
{
|
||||
@@ -63,8 +59,6 @@ private:
|
||||
MutableBufferSequence buffers_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/shutdown_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -28,8 +26,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
class shutdown_op
|
||||
{
|
||||
public:
|
||||
@@ -46,12 +42,20 @@ public:
|
||||
const boost::system::error_code& ec,
|
||||
const std::size_t&) const
|
||||
{
|
||||
handler(ec);
|
||||
if (ec == boost::asio::error::eof)
|
||||
{
|
||||
// The engine only generates an eof when the shutdown notification has
|
||||
// been received from the peer. This indicates that the shutdown has
|
||||
// completed successfully, and thus need not be passed on to the handler.
|
||||
handler(boost::system::error_code());
|
||||
}
|
||||
else
|
||||
{
|
||||
handler(ec);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/stream_core.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,15 +17,13 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
# include <boost/asio/deadline_timer.hpp>
|
||||
# else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
# include <boost/asio/steady_timer.hpp>
|
||||
# endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
# include <boost/asio/buffer.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#if defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
# include <boost/asio/deadline_timer.hpp>
|
||||
#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
# include <boost/asio/steady_timer.hpp>
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -34,18 +32,17 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
struct stream_core
|
||||
{
|
||||
// According to the OpenSSL documentation, this is the buffer size that is
|
||||
// sufficient to hold the largest possible TLS record.
|
||||
enum { max_tls_record_size = 17 * 1024 };
|
||||
|
||||
stream_core(SSL_CTX* context, boost::asio::io_service& io_service)
|
||||
template <typename Executor>
|
||||
stream_core(SSL_CTX* context, const Executor& ex)
|
||||
: engine_(context),
|
||||
pending_read_(io_service),
|
||||
pending_write_(io_service),
|
||||
pending_read_(ex),
|
||||
pending_write_(ex),
|
||||
output_buffer_space_(max_tls_record_size),
|
||||
output_buffer_(boost::asio::buffer(output_buffer_space_)),
|
||||
input_buffer_space_(max_tls_record_size),
|
||||
@@ -80,6 +77,13 @@ struct stream_core
|
||||
{
|
||||
return boost::posix_time::pos_infin;
|
||||
}
|
||||
|
||||
// Helper function to get a timer's expiry time.
|
||||
static boost::asio::deadline_timer::time_type expiry(
|
||||
const boost::asio::deadline_timer& timer)
|
||||
{
|
||||
return timer.expires_at();
|
||||
}
|
||||
#else // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
// Timer used for storing queued read operations.
|
||||
boost::asio::steady_timer pending_read_;
|
||||
@@ -98,26 +102,31 @@ struct stream_core
|
||||
{
|
||||
return (boost::asio::steady_timer::time_point::max)();
|
||||
}
|
||||
|
||||
// Helper function to get a timer's expiry time.
|
||||
static boost::asio::steady_timer::time_point expiry(
|
||||
const boost::asio::steady_timer& timer)
|
||||
{
|
||||
return timer.expiry();
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_DATE_TIME)
|
||||
|
||||
// Buffer space used to prepare output intended for the transport.
|
||||
std::vector<unsigned char> output_buffer_space_;
|
||||
|
||||
// A buffer that may be used to prepare output intended for the transport.
|
||||
const boost::asio::mutable_buffers_1 output_buffer_;
|
||||
const boost::asio::mutable_buffer output_buffer_;
|
||||
|
||||
// Buffer space used to read input intended for the engine.
|
||||
std::vector<unsigned char> input_buffer_space_;
|
||||
|
||||
// A buffer that may be used to read input intended for the engine.
|
||||
const boost::asio::mutable_buffers_1 input_buffer_;
|
||||
const boost::asio::mutable_buffer input_buffer_;
|
||||
|
||||
// The buffer pointing to the engine's unconsumed input.
|
||||
boost::asio::const_buffer input_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/verify_callback.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/ssl/verify_context.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/ssl/verify_context.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -28,8 +26,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
class verify_callback_base
|
||||
{
|
||||
public:
|
||||
@@ -58,8 +54,6 @@ private:
|
||||
VerifyCallback callback_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ssl/detail/write_op.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -17,10 +17,8 @@
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
# include <boost/asio/detail/buffer_sequence_adapter.hpp>
|
||||
# include <boost/asio/ssl/detail/engine.hpp>
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
#include <boost/asio/detail/buffer_sequence_adapter.hpp>
|
||||
#include <boost/asio/ssl/detail/engine.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
@@ -29,8 +27,6 @@ namespace asio {
|
||||
namespace ssl {
|
||||
namespace detail {
|
||||
|
||||
#if !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
template <typename ConstBufferSequence>
|
||||
class write_op
|
||||
{
|
||||
@@ -63,8 +59,6 @@ private:
|
||||
ConstBufferSequence buffers_;
|
||||
};
|
||||
|
||||
#endif // !defined(BOOST_ASIO_ENABLE_OLD_SSL)
|
||||
|
||||
} // namespace detail
|
||||
} // namespace ssl
|
||||
} // namespace asio
|
||||
|
||||
Reference in New Issue
Block a user