From b43f96f322abe956d0864694af3e8c1bf9e1d7dc Mon Sep 17 00:00:00 2001 From: Kari Oikarinen Date: Wed, 22 Feb 2017 13:31:13 +0200 Subject: Close streams when resetting Connection The streams were only destroyed, not closed. This meant that ongoing Services would have a dangling pointer. Also only reset the connection once in response to Invalid messages. Change-Id: I35ccb149986a76ee9abf9182923ee40bd5174373 Reviewed-by: Samuli Piippo --- qdb/server/connection.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qdb/server/connection.cpp b/qdb/server/connection.cpp index 03f2693..2b13666 100644 --- a/qdb/server/connection.cpp +++ b/qdb/server/connection.cpp @@ -116,7 +116,8 @@ void Connection::handleMessage() if (message.command() == QdbMessage::Invalid) { qCCritical(connectionC) << "Connection received invalid message!"; - resetConnection(false); + if (m_state != ConnectionState::Disconnected) + resetConnection(false); return; } @@ -276,6 +277,10 @@ void Connection::resetConnection(bool reconnect) m_outgoingMessages.clear(); m_state = ConnectionState::Disconnected; m_streamRequests.clear(); + for (const auto &pair : m_streams) { + const auto &stream = pair.second; + stream->close(); + } m_streams.clear(); if (reconnect) -- cgit v1.2.3