Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreidheim <eidheim@gmail.com>2021-11-07 21:19:01 +0300
committereidheim <eidheim@gmail.com>2021-11-07 21:19:01 +0300
commit639d5a40b4d67217393b38367de069e7c27fe2ec (patch)
treeaef61f627bf56d5602f12d5291c7782b8a925f70 /server_ws.hpp
parent298c66c9afb719d22fbc14c5171a45d571ba9309 (diff)
Fixes #175 : client timeout will now eventually close connection when the connection is abruptly closed
Diffstat (limited to 'server_ws.hpp')
-rw-r--r--server_ws.hpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/server_ws.hpp b/server_ws.hpp
index c41ecfa..991b29d 100644
--- a/server_ws.hpp
+++ b/server_ws.hpp
@@ -79,7 +79,7 @@ namespace SimpleWeb {
friend class SocketServer<socket_type>;
public:
- Connection(std::unique_ptr<socket_type> &&socket_) noexcept : socket(std::move(socket_)), timeout_idle(0), closed(false) {}
+ Connection(std::unique_ptr<socket_type> &&socket_) noexcept : socket(std::move(socket_)), timeout_idle(0), close_sent(false) {}
std::string method, path, query_string, http_version;
@@ -91,7 +91,7 @@ namespace SimpleWeb {
/// Used to call SocketServer::upgrade.
template <typename... Args>
Connection(std::shared_ptr<ScopeRunner> handler_runner_, long timeout_idle, Args &&...args) noexcept
- : handler_runner(std::move(handler_runner_)), socket(new socket_type(std::forward<Args>(args)...)), timeout_idle(timeout_idle), closed(false) {}
+ : handler_runner(std::move(handler_runner_)), socket(new socket_type(std::forward<Args>(args)...)), timeout_idle(timeout_idle), close_sent(false) {}
std::shared_ptr<ScopeRunner> handler_runner;
@@ -105,7 +105,7 @@ namespace SimpleWeb {
Mutex timer_mutex;
std::unique_ptr<asio::steady_timer> timer GUARDED_BY(timer_mutex);
- std::atomic<bool> closed;
+ std::atomic<bool> close_sent;
asio::ip::tcp::endpoint endpoint; // The endpoint is read in SocketServer::write_handshake and must be stored so that it can be read reliably in all handlers, including on_error
@@ -238,9 +238,9 @@ namespace SimpleWeb {
void send_close(int status, const std::string &reason = "", std::function<void(const error_code &)> callback = nullptr) {
// Send close only once (in case close is initiated by server)
- if(closed)
+ if(close_sent)
return;
- closed = true;
+ close_sent = true;
auto send_stream = std::make_shared<OutMessage>();