diff --git a/include/libtorrent/variant_stream.hpp b/include/libtorrent/variant_stream.hpp index 3551f5c9e..f89a9527d 100644 --- a/include/libtorrent/variant_stream.hpp +++ b/include/libtorrent/variant_stream.hpp @@ -542,9 +542,11 @@ public: } template - S& get() + S* get() { - return *boost::get(m_variant); + S** ret = boost::get(&m_variant); + if (!ret) return 0; + return *ret; } bool instantiated() const diff --git a/src/http_connection.cpp b/src/http_connection.cpp index 73904dae6..84b750fc9 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -163,15 +163,16 @@ void http_connection::start(std::string const& hostname, std::string const& port if (m_ssl) { m_sock.instantiate >(m_resolver.get_io_service()); - ssl_stream& s = m_sock.get >(); - bool ret = instantiate_connection(m_resolver.get_io_service(), m_proxy, s.next_layer()); + ssl_stream* s = m_sock.get >(); + TORRENT_ASSERT(s); + bool ret = instantiate_connection(m_resolver.get_io_service(), m_proxy, s->next_layer()); TORRENT_ASSERT(ret); } else { m_sock.instantiate(m_resolver.get_io_service()); bool ret = instantiate_connection(m_resolver.get_io_service() - , m_proxy, m_sock.get()); + , m_proxy, *m_sock.get()); TORRENT_ASSERT(ret); } #else diff --git a/src/instantiate_connection.cpp b/src/instantiate_connection.cpp index 776ab6a12..1c69ecd35 100644 --- a/src/instantiate_connection.cpp +++ b/src/instantiate_connection.cpp @@ -52,23 +52,23 @@ namespace libtorrent || ps.type == proxy_settings::http_pw) { s.instantiate(ios); - s.get().set_proxy(ps.hostname, ps.port); + s.get()->set_proxy(ps.hostname, ps.port); if (ps.type == proxy_settings::http_pw) - s.get().set_username(ps.username, ps.password); + s.get()->set_username(ps.username, ps.password); } else if (ps.type == proxy_settings::socks5 || ps.type == proxy_settings::socks5_pw) { s.instantiate(ios); - s.get().set_proxy(ps.hostname, ps.port); + s.get()->set_proxy(ps.hostname, ps.port); if (ps.type == proxy_settings::socks5_pw) - s.get().set_username(ps.username, ps.password); + s.get()->set_username(ps.username, ps.password); } else if (ps.type == proxy_settings::socks4) { s.instantiate(ios); - s.get().set_proxy(ps.hostname, ps.port); - s.get().set_username(ps.username); + s.get()->set_proxy(ps.hostname, ps.port); + s.get()->set_username(ps.username); } else { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index e71dbe8d9..8f9d594b5 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -772,7 +772,7 @@ namespace aux { { shared_ptr c(new socket_type(m_io_service)); c->instantiate(m_io_service); - listener->async_accept(c->get() + listener->async_accept(*c->get() , bind(&session_impl::on_incoming_connection, this, c , boost::weak_ptr(listener), _1)); } diff --git a/src/torrent.cpp b/src/torrent.cpp index 81f27168c..3baf03078 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2335,7 +2335,7 @@ namespace libtorrent { // the web seed connection will talk immediately to // the proxy, without requiring CONNECT support - s->get().set_no_connect(true); + s->get()->set_no_connect(true); } boost::intrusive_ptr c(new (std::nothrow) web_peer_connection(