1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 00:54:20 +02:00

Only setup a Connection once

This commit is contained in:
Uwe L. Korn
2013-06-29 09:03:03 +02:00
committed by Michael Zanetti
parent cf93741079
commit ff8e905599
2 changed files with 42 additions and 30 deletions

View File

@@ -400,7 +400,7 @@ Connection::doSetup()
{
Q_D( Connection );
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << thread();
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << thread() << d->id;
/*
New connections can be created from other thread contexts, such as
when AudioEngine calls getIODevice.. - we need to ensure that connections
@@ -414,6 +414,11 @@ Connection::doSetup()
moveToThread( d->servent->thread() );
}
if ( !d->setup )
{
// We only want to setup this connection once
d->setup = true;
//stats timer calculates BW used by this connection
d->statstimer = new QTimer;
d->statstimer->moveToThread( this->thread() );
@@ -448,6 +453,11 @@ Connection::doSetup()
{
sendMsg( Msg::factory( PROTOVER, Msg::SETUP ) );
}
}
else
{
tLog() << Q_FUNC_INFO << QThread::currentThread() << d->id << "Duplicate doSetup call";
}
// call readyRead incase we missed the signal in between the servent disconnecting and us
// connecting to the signal - won't do anything if there are no bytesAvailable anyway.

View File

@@ -41,6 +41,7 @@ public:
, peer_disconnected( false )
, ready( false )
, onceonly( true )
, setup( false )
, tx_bytes( 0 )
, tx_bytes_requested( 0 )
, rx_bytes( 0 )
@@ -66,6 +67,7 @@ private:
bool outbound;
bool ready;
bool onceonly;
bool setup;
qint64 tx_bytes;
qint64 tx_bytes_requested;
qint64 rx_bytes;