From 84884ff9cd98bfb44409ba2068b512fdb6190610 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Mon, 13 Feb 2012 06:57:15 -0600 Subject: [PATCH] fixes #55 --- src/endpoint.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/endpoint.hpp b/src/endpoint.hpp index 48f0e354b4..337466ceb7 100644 --- a/src/endpoint.hpp +++ b/src/endpoint.hpp @@ -215,8 +215,11 @@ public: // TODO: is there a more elegant way to do this? In some code paths // close can call terminate immediately which removes the connection // from m_connections, invalidating the iterator. - while(!m_connections.empty()) { - (*m_connections.begin())->close(code,reason); + typename std::set::iterator it; + + for (it = m_connections.begin(); it != m_connections.end();) { + const connection_ptr con = *it++; + con->close(code,reason); } } @@ -442,14 +445,14 @@ struct endpoint_traits< endpoint > { * @param connection A shared pointer to the connection that was transferred * @param old_handler A shared pointer to the previous handler */ - virtual void on_load(connection_ptr connection, handler_ptr old_handler) {} + virtual void on_load(connection_ptr con, handler_ptr old_handler) {} /// on_unload is the last callback called for a handler before control /// of a connection is handed over to a new handler mid flight. /** * @param connection A shared pointer to the connection being transferred * @param old_handler A shared pointer to the new handler */ - virtual void on_unload(connection_ptr connection, handler_ptr new_handler) {} + virtual void on_unload(connection_ptr con, handler_ptr new_handler) {} }; };