mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Do not delete connection if PeerInfo disappers during connect
This commit is contained in:
@@ -116,6 +116,7 @@ ConnectionManager::connectToPeer( const Tomahawk::peerinfo_ptr &peerInfo, bool l
|
|||||||
m["nodeid"] = Database::instance()->impl()->dbid();
|
m["nodeid"] = Database::instance()->impl()->dbid();
|
||||||
|
|
||||||
m_controlConnection = QPointer<ControlConnection>( new ControlConnection( Servent::instance() ) );
|
m_controlConnection = QPointer<ControlConnection>( new ControlConnection( Servent::instance() ) );
|
||||||
|
m_controlConnection->setShutdownOnEmptyPeerInfos( false );
|
||||||
m_controlConnection->addPeerInfo( peerInfo );
|
m_controlConnection->addPeerInfo( peerInfo );
|
||||||
m_controlConnection->setFirstMessage( m );
|
m_controlConnection->setFirstMessage( m );
|
||||||
|
|
||||||
@@ -238,6 +239,8 @@ ConnectionManager::handoverSocket( QTcpSocketExtra* sock )
|
|||||||
m_controlConnection->setPeerPort( sock->peerPort() );
|
m_controlConnection->setPeerPort( sock->peerPort() );
|
||||||
|
|
||||||
m_controlConnection->start( sock );
|
m_controlConnection->start( sock );
|
||||||
|
// ControlConntection is now connected, now it can be destroyed if the PeerInfos disappear
|
||||||
|
m_controlConnection->setShutdownOnEmptyPeerInfos( true );
|
||||||
m_currentPeerInfo.clear();
|
m_currentPeerInfo.clear();
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@ ControlConnection::ControlConnection( Servent* parent )
|
|||||||
, m_dbsyncconn( 0 )
|
, m_dbsyncconn( 0 )
|
||||||
, m_registered( false )
|
, m_registered( false )
|
||||||
, m_pingtimer( 0 )
|
, m_pingtimer( 0 )
|
||||||
|
, m_shutdownOnEmptyPeerInfos( true )
|
||||||
{
|
{
|
||||||
qDebug() << "CTOR controlconnection";
|
qDebug() << "CTOR controlconnection";
|
||||||
setId("ControlConnection()");
|
setId("ControlConnection()");
|
||||||
@@ -305,7 +306,17 @@ ControlConnection::removePeerInfo( const peerinfo_ptr& peerInfo )
|
|||||||
|
|
||||||
m_peerInfos.remove( peerInfo );
|
m_peerInfos.remove( peerInfo );
|
||||||
|
|
||||||
if ( m_peerInfos.isEmpty() )
|
if ( m_peerInfos.isEmpty() && m_shutdownOnEmptyPeerInfos )
|
||||||
|
{
|
||||||
|
shutdown( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ControlConnection::setShutdownOnEmptyPeerInfos( bool shutdownOnEmptyPeerInfos )
|
||||||
|
{
|
||||||
|
m_shutdownOnEmptyPeerInfos = shutdownOnEmptyPeerInfos;
|
||||||
|
if ( m_peerInfos.isEmpty() && m_shutdownOnEmptyPeerInfos )
|
||||||
{
|
{
|
||||||
shutdown( true );
|
shutdown( true );
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ public:
|
|||||||
|
|
||||||
void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
||||||
void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
||||||
|
void setShutdownOnEmptyPeerInfos( bool shutdownOnEmptyPeerInfos );
|
||||||
const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
|
const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -71,6 +72,7 @@ private:
|
|||||||
|
|
||||||
QString m_dbconnkey;
|
QString m_dbconnkey;
|
||||||
bool m_registered;
|
bool m_registered;
|
||||||
|
bool m_shutdownOnEmptyPeerInfos;
|
||||||
|
|
||||||
QTimer* m_pingtimer;
|
QTimer* m_pingtimer;
|
||||||
QTime m_pingtimer_mark;
|
QTime m_pingtimer_mark;
|
||||||
|
Reference in New Issue
Block a user