From 16d30a1072b54c7835df53ffa529a0ad96acf584 Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Fri, 17 May 2013 00:25:37 +0200 Subject: [PATCH] Only destroy existing ControlConnection if it does not run anymore --- src/libtomahawk/network/Servent.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/network/Servent.cpp b/src/libtomahawk/network/Servent.cpp index b70cd330c..aae34489b 100644 --- a/src/libtomahawk/network/Servent.cpp +++ b/src/libtomahawk/network/Servent.cpp @@ -789,8 +789,15 @@ Servent::connectToPeer( const peerinfo_ptr& peerInfo ) peerInfoDebug( peerInfo ) << "connectToPeer: search for already established connections to the same nodeid:" << m_controlconnections.count() << "connections"; if ( peerInfo->controlConnection() ) { - peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "deleting the existing Controlconnection"; - delete peerInfo->controlConnection(); + if ( peerInfo->controlConnection()->isReady() && peerInfo->controlConnection()->isRunning() ) { + peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "We have a running ControlConnection, so no use to connect."; + return; + } + else + { + peerInfoDebug( peerInfo ) << Q_FUNC_INFO << "deleting the existing ControlConnection"; + delete peerInfo->controlConnection(); + } } bool isDupe = false;