update socket member functions to the new API (cancel, set_option, get_option)

This commit is contained in:
arvidn
2019-01-25 23:52:40 +01:00
committed by Arvid Norberg
parent 01a7d40ad2
commit 6348b5def5
5 changed files with 29 additions and 32 deletions

View File

@ -256,8 +256,8 @@ namespace aux {
#endif
template <class SettableSocketOption>
error_code set_option(SettableSocketOption const& opt, error_code& ec)
{ TORRENT_SOCKTYPE_FORWARD_RET(set_option(opt, ec), ec) }
void set_option(SettableSocketOption const& opt, error_code& ec)
{ TORRENT_SOCKTYPE_FORWARD(set_option(opt, ec)) }
void non_blocking(bool b, error_code& ec)
{ TORRENT_SOCKTYPE_FORWARD(non_blocking(b, ec)) }
@ -274,8 +274,8 @@ namespace aux {
#endif
template <class GettableSocketOption>
error_code get_option(GettableSocketOption& opt, error_code& ec)
{ TORRENT_SOCKTYPE_FORWARD_RET(get_option(opt, ec), ec) }
void get_option(GettableSocketOption& opt, error_code& ec)
{ TORRENT_SOCKTYPE_FORWARD(get_option(opt, ec)) }
template <class S>
void instantiate(io_context& ios, void* userdata = nullptr)

View File

@ -129,9 +129,9 @@ public:
}
#endif
error_code non_blocking(bool b, error_code& ec)
void non_blocking(bool b, error_code& ec)
{
return m_sock.non_blocking(b, ec);
m_sock.non_blocking(b, ec);
}
#ifndef BOOST_NO_EXCEPTIONS
@ -143,9 +143,9 @@ public:
#endif
template <class SettableSocketOption>
error_code set_option(SettableSocketOption const& opt, error_code& ec)
void set_option(SettableSocketOption const& opt, error_code& ec)
{
return m_sock.set_option(opt, ec);
m_sock.set_option(opt, ec);
}
#ifndef BOOST_NO_EXCEPTIONS
@ -157,9 +157,9 @@ public:
#endif
template <class GettableSocketOption>
error_code get_option(GettableSocketOption& opt, error_code& ec)
void get_option(GettableSocketOption& opt, error_code& ec)
{
return m_sock.get_option(opt, ec);
m_sock.get_option(opt, ec);
}
#ifndef BOOST_NO_EXCEPTIONS
@ -169,9 +169,14 @@ public:
}
#endif
error_code cancel(error_code& ec)
void cancel()
{
return m_sock.cancel(ec);
m_sock.cancel();
}
void cancel(error_code& ec)
{
m_sock.cancel(ec);
}
void bind(endpoint_type const& /* endpoint */, error_code& /* ec */)

View File

@ -79,10 +79,8 @@ public:
using lowest_layer_type = typename Stream::lowest_layer_type;
using endpoint_type = typename Stream::endpoint_type;
using protocol_type = typename Stream::protocol_type;
#if BOOST_VERSION >= 106600
using executor_type = typename sock_type::executor_type;
executor_type get_executor() { return m_sock.get_executor(); }
#endif
void set_host_name(std::string const& name)
{
@ -163,9 +161,9 @@ public:
#endif
template <class SettableSocketOption>
error_code set_option(SettableSocketOption const& opt, error_code& ec)
void set_option(SettableSocketOption const& opt, error_code& ec)
{
return m_sock.next_layer().set_option(opt, ec);
m_sock.next_layer().set_option(opt, ec);
}
#ifndef BOOST_NO_EXCEPTIONS
@ -177,9 +175,9 @@ public:
#endif
template <class GettableSocketOption>
error_code get_option(GettableSocketOption& opt, error_code& ec)
void get_option(GettableSocketOption& opt, error_code& ec)
{
return m_sock.next_layer().get_option(opt, ec);
m_sock.next_layer().get_option(opt, ec);
}
#ifndef BOOST_NO_EXCEPTIONS
@ -206,8 +204,8 @@ public:
void non_blocking(bool b) { m_sock.next_layer().non_blocking(b); }
#endif
error_code non_blocking(bool b, error_code& ec)
{ return m_sock.next_layer().non_blocking(b, ec); }
void non_blocking(bool b, error_code& ec)
{ m_sock.next_layer().non_blocking(b, ec); }
template <class Const_Buffers, class Handler>
void async_write_some(Const_Buffers const& buffers, Handler const& handler)
@ -297,11 +295,6 @@ public:
return const_cast<sock_type&>(m_sock).next_layer().local_endpoint(ec);
}
io_context& get_executor()
{
return m_sock.get_executor();
}
lowest_layer_type& lowest_layer()
{
return m_sock.lowest_layer();

View File

@ -215,7 +215,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
void non_blocking(bool) {}
#endif
error_code non_blocking(bool, error_code&) { return error_code(); }
void non_blocking(bool, error_code&) {}
#ifndef BOOST_NO_EXCEPTIONS
void bind(endpoint_type const& /*endpoint*/) {}
@ -229,7 +229,7 @@ struct TORRENT_EXTRA_EXPORT utp_stream
#endif
template <class SettableSocketOption>
error_code set_option(SettableSocketOption const&, error_code& ec) { return ec; }
void set_option(SettableSocketOption const&, error_code&) { }
#ifndef BOOST_NO_EXCEPTIONS
template <class GettableSocketOption>
@ -237,13 +237,11 @@ struct TORRENT_EXTRA_EXPORT utp_stream
#endif
template <class GettableSocketOption>
error_code get_option(GettableSocketOption&, error_code& ec)
{ return ec; }
void get_option(GettableSocketOption&, error_code&) {}
error_code cancel(error_code&)
void cancel(error_code&)
{
cancel_handlers(boost::asio::error::operation_aborted);
return error_code();
}
void close();

View File

@ -320,11 +320,12 @@ void http_connection::start(std::string const& hostname, int port
if (m_ssl_ctx)
{
m_own_ssl_context = true;
error_code ec;
m_ssl_ctx->set_verify_mode(ssl::context::verify_none, ec);
if (ec)
{
post(m_timer.get_executor(), std::bind(&http_connection::callback
, me, ec, span<char>{}));
, me, ec, span<char>{}));
return;
}
}