Skip to content

Replacing boost::bind and boost::enable_shared_form_this by std counterparts #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove boost::bind/shared_ptr from client
From here on out only use the standard-provided shared pointer
implementations. Also use the native C++11 features for deleting special
member implementations.
  • Loading branch information
deanberris authored and torbjoernk committed Apr 13, 2013
commit 0dc73083b661de427d582fda5a62cb2fc89b37cb
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,18 @@ struct http_async_connection_pimpl
boost::system::error_code const& ec,
std::size_t bytes_transferred) {
NETWORK_MESSAGE("http_async_connection_pimpl::handle_received_data(...)");
#ifdef NETWORK_ENABLE_HTTPS
// Okay, there's some weirdness with Boost.Asio's handling of SSL errors
// so we need to do some acrobatics to make sure that we're handling the
// short-read errors correctly. This is such a PITA that we have to deal
// with this here.
static long short_read_error = 335544539;
constexpr static long short_read_error = 335544539;
bool is_short_read_error =
#ifdef NETWORK_ENABLE_HTTPS
ec.category() == boost::asio::error::ssl_category &&
ec.value() == short_read_error
(ec.category() == boost::asio::error::ssl_category) &&
(ec.value() == short_read_error);
#else
false
constexpr bool is_short_read_error = false;
#endif
;
if (!ec || ec == boost::asio::error::eof || is_short_read_error) {
NETWORK_MESSAGE("processing data chunk, no error encountered so far...");
boost::logic::tribool parsed_ok;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ struct connection_delegate_factory {
virtual ~connection_delegate_factory();

private:
connection_delegate_factory(connection_delegate_factory const&); // = delete
connection_delegate_factory& operator=(
connection_delegate_factory); // = delete
connection_delegate_factory(connection_delegate_factory const &) = delete;
connection_delegate_factory &operator=(connection_delegate_factory) = delete;
};

} // namespace http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ connection_delegate_factory::connection_delegate_ptr connection_delegate_factory
if (https) {
#ifdef NETWORK_ENABLE_HTTPS
NETWORK_MESSAGE("creating an SSL delegate");
delegate.reset(new ssl_delegate(service, options));
std::shared_ptr<ssl_delegate> delegate_ptr(new ssl_delegate(service, options));
delegate = std::move(delegate_ptr);
#else
NETWORK_MESSAGE("creating an SSL delegate, but not supported");
BOOST_THROW_EXCEPTION(std::runtime_error("HTTPS not supported."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct normal_delegate : connection_delegate {
boost::asio::io_service& service_;
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;

normal_delegate(normal_delegate const&); // = delete
normal_delegate& operator=(normal_delegate); // = delete
normal_delegate(normal_delegate const&) = delete;
normal_delegate& operator=(normal_delegate) = delete;
};

} // namespace http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <boost/asio/ssl.hpp>
#include <network/protocol/http/client/connection/connection_delegate.hpp>
#include <network/protocol/http/client/options.hpp>
#include <boost/enable_shared_from_this.hpp>

namespace boost {
namespace asio {
Expand All @@ -23,7 +22,7 @@ namespace network {
namespace http {

struct ssl_delegate : connection_delegate,
boost::enable_shared_from_this<ssl_delegate> {
std::enable_shared_from_this<ssl_delegate> {
ssl_delegate(boost::asio::io_service& service, client_options const& options);

virtual void connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <network/protocol/http/client/options.hpp>
#include <network/protocol/http/client/connection/ssl_delegate.hpp>
#include <boost/asio/placeholders.hpp>
#include <functional>
#include <network/detail/debug.hpp>

network::http::ssl_delegate::ssl_delegate(boost::asio::io_service& service,
Expand Down Expand Up @@ -48,8 +47,7 @@ void network::http::ssl_delegate::connect(
} else {
NETWORK_MESSAGE("not verifying peer");
context_->set_default_verify_paths();
context_->set_verify_mode(boost::asio::ssl::context::verify_peer);
context_->set_verify_callback(boost::asio::ssl::rfc2818_verification(host));
context_->set_verify_mode(boost::asio::ssl::context::verify_none);
}
socket_.reset(new boost::asio::ssl::stream<
boost::asio::ip::tcp::socket>(service_, *context_));
Expand Down