diff --git a/server_http.hpp b/server_http.hpp index 0a83c9b..48b223e 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -538,6 +538,14 @@ namespace SimpleWeb { if(on_upgrade) { auto it = session->request->header.find("Upgrade"); if(it != session->request->header.end()) { + // remove connection from connections + { + std::unique_lock lock(*connections_mutex); + auto it = connections->find(session->connection.get()); + if(it != connections->end()) + connections->erase(it); + } + on_upgrade(session->connection->socket, session->request); return; }