Avoid leak when stopping server

If accept fails, e.g., because the server is no longer listening the
connection object is not terminated and it results in a memory leak:
connection -> handler -> connection.
This commit is contained in:
Aydan Yumerefendi
2014-03-03 21:51:56 -05:00
parent 337bf2fb0a
commit 3ca53d0064

View File

@@ -104,7 +104,13 @@ public:
endpoint_type::m_elog.write(log::elevel::rerror,
"start_accept error: "+ec.message());
}
}
if (ec) {
// Terminate the connection to prevent memory leaks.
lib::error_code con_ec;
con->terminate(con_ec);
}
}
void handle_accept(connection_ptr con, lib::error_code const & ec) {
if (ec) {