diff --git a/include/bitcoin/network/net/proxy.hpp b/include/bitcoin/network/net/proxy.hpp index 6377a9db1..d8958b1c3 100644 --- a/include/bitcoin/network/net/proxy.hpp +++ b/include/bitcoin/network/net/proxy.hpp @@ -97,7 +97,7 @@ class BCT_API proxy /// Connection is currently secured (TLS or comparable for socket type). bool secure() const NOEXCEPT; - /// The socket was upgraded to a websocket (requires strand). + /// The socket was upgraded to a websocket. bool websocket() const NOEXCEPT; /// The total number of bytes queued/sent to the remote endpoint. diff --git a/include/bitcoin/network/net/socket.hpp b/include/bitcoin/network/net/socket.hpp index 63defeb2c..1c44191bc 100644 --- a/include/bitcoin/network/net/socket.hpp +++ b/include/bitcoin/network/net/socket.hpp @@ -194,7 +194,7 @@ class BCT_API socket /// The socket upgrades to its secure configuration upon connect. virtual bool secure() const NOEXCEPT; - /// The socket was upgraded to a websocket (requires strand). + /// The socket was upgraded to a websocket. virtual bool websocket() const NOEXCEPT; /// Get the address of the outgoing endpoint passed via construct, or the @@ -406,6 +406,7 @@ class BCT_API socket asio::context& service_; const context& context_; std::atomic_bool stopped_{}; + std::atomic_bool websocket_{}; // These are protected by strand (see also handle_accept). config::address address_; diff --git a/src/net/socket.cpp b/src/net/socket.cpp index 17a6af12d..db2a38e3c 100644 --- a/src/net/socket.cpp +++ b/src/net/socket.cpp @@ -116,9 +116,7 @@ bool socket::inbound() const NOEXCEPT bool socket::websocket() const NOEXCEPT { - BC_ASSERT(stranded()); - return std::holds_alternative(socket_) || - std::holds_alternative(socket_); + return websocket_.load(); } const config::address& socket::address() const NOEXCEPT diff --git a/src/net/socket_ws.cpp b/src/net/socket_ws.cpp index 80cd00a85..5b3bbe011 100644 --- a/src/net/socket_ws.cpp +++ b/src/net/socket_ws.cpp @@ -173,6 +173,7 @@ code socket::set_websocket(const http::request& request) NOEXCEPT sock.accept(request); } + websocket_.store(true); return error::upgraded; } catch (const std::exception& e)