mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 15:59:42 +01:00
Do not delete connection if PeerInfo disappers during connect
This commit is contained in:
parent
8610c156eb
commit
18e1340de9
@ -116,6 +116,7 @@ ConnectionManager::connectToPeer( const Tomahawk::peerinfo_ptr &peerInfo, bool l
|
||||
m["nodeid"] = Database::instance()->impl()->dbid();
|
||||
|
||||
m_controlConnection = QPointer<ControlConnection>( new ControlConnection( Servent::instance() ) );
|
||||
m_controlConnection->setShutdownOnEmptyPeerInfos( false );
|
||||
m_controlConnection->addPeerInfo( peerInfo );
|
||||
m_controlConnection->setFirstMessage( m );
|
||||
|
||||
@ -238,6 +239,8 @@ ConnectionManager::handoverSocket( QTcpSocketExtra* sock )
|
||||
m_controlConnection->setPeerPort( sock->peerPort() );
|
||||
|
||||
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_mutex.unlock();
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ ControlConnection::ControlConnection( Servent* parent )
|
||||
, m_dbsyncconn( 0 )
|
||||
, m_registered( false )
|
||||
, m_pingtimer( 0 )
|
||||
, m_shutdownOnEmptyPeerInfos( true )
|
||||
{
|
||||
qDebug() << "CTOR controlconnection";
|
||||
setId("ControlConnection()");
|
||||
@ -305,7 +306,17 @@ ControlConnection::removePeerInfo( const peerinfo_ptr& 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 );
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
|
||||
void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
||||
void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
|
||||
void setShutdownOnEmptyPeerInfos( bool shutdownOnEmptyPeerInfos );
|
||||
const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
|
||||
|
||||
protected:
|
||||
@ -71,6 +72,7 @@ private:
|
||||
|
||||
QString m_dbconnkey;
|
||||
bool m_registered;
|
||||
bool m_shutdownOnEmptyPeerInfos;
|
||||
|
||||
QTimer* m_pingtimer;
|
||||
QTime m_pingtimer_mark;
|
||||
|
Loading…
x
Reference in New Issue
Block a user