1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 09:19:41 +01:00

Don't send config message to resolvers more than once

This commit is contained in:
Leo Franchi 2011-09-12 11:19:42 -04:00
parent 2bc71743de
commit aeeff01d64
3 changed files with 11 additions and 6 deletions

View File

@ -51,7 +51,7 @@ Pipeline::Pipeline( QObject* parent )
s_instance = this;
m_maxConcurrentQueries = qBound( DEFAULT_CONCURRENT_QUERIES, QThread::idealThreadCount(), MAX_CONCURRENT_QUERIES );
qDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentQueries << "threads";
tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentQueries << "threads";
m_temporaryQueryTimer.setInterval( CLEANUP_TIMEOUT );
connect( &m_temporaryQueryTimer, SIGNAL( timeout() ), SLOT( onTemporaryQueryTimer() ) );
@ -79,7 +79,7 @@ Pipeline::databaseReady()
void
Pipeline::start()
{
qDebug() << Q_FUNC_INFO << "Shunting this many pending queries:" << m_queries_pending.size();
tDebug() << Q_FUNC_INFO << "Shunting this many pending queries:" << m_queries_pending.size();
m_running = true;
shuntNext();
@ -108,7 +108,7 @@ Pipeline::addResolver( Resolver* r )
{
QMutexLocker lock( &m_mut );
qDebug() << "Adding resolver" << r->name();
tDebug() << "Adding resolver" << r->name();
m_resolvers.append( r );
emit resolverAdded( r );
}
@ -448,7 +448,7 @@ void
Pipeline::onTemporaryQueryTimer()
{
QMutexLocker lock( &m_mut );
qDebug() << Q_FUNC_INFO;
tDebug() << Q_FUNC_INFO;
m_temporaryQueryTimer.stop();
for ( int i = m_queries_temporary.count() - 1; i >= 0; i-- )

View File

@ -37,6 +37,7 @@ ScriptResolver::ScriptResolver( const QString& exe )
, m_msgsize( 0 )
, m_ready( false )
, m_stopped( true )
, m_configSent( false )
, m_error( Tomahawk::ExternalResolver::NoError )
{
tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
@ -79,8 +80,9 @@ ScriptResolver::start()
m_stopped = false;
if ( m_ready )
Tomahawk::Pipeline::instance()->addResolver( this );
else
else if ( !m_configSent )
sendConfig();
// else, we've sent our config msg so are waiting for the resolver to react
}
@ -92,6 +94,8 @@ ScriptResolver::sendConfig()
QVariantMap m;
m.insert( "_msgtype", "config" );
m_configSent = true;
TomahawkUtils::NetworkProxyFactory* factory = dynamic_cast<TomahawkUtils::NetworkProxyFactory*>( TomahawkUtils::nam()->proxyFactory() );
QNetworkProxy proxy = factory->proxy();
QString proxyType = ( proxy.type() == QNetworkProxy::Socks5Proxy ? "socks5" : "none" );
@ -323,6 +327,7 @@ ScriptResolver::doSetup( const QVariantMap& m )
qDebug() << "SCRIPT" << filePath() << "READY," << "name" << m_name << "weight" << m_weight << "timeout" << m_timeout;
m_ready = true;
m_configSent = false;
if ( !m_stopped )
Tomahawk::Pipeline::instance()->addResolver( this );

View File

@ -82,7 +82,7 @@ private:
quint32 m_msgsize;
QByteArray m_msg;
bool m_ready, m_stopped;
bool m_ready, m_stopped, m_configSent;
ExternalResolver::ErrorState m_error;
QJson::Parser m_parser;