mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Fixed PING/PONG timeout.
This commit is contained in:
@@ -119,7 +119,7 @@ private:
|
|||||||
QString m_id;
|
QString m_id;
|
||||||
|
|
||||||
QTimer* m_statstimer;
|
QTimer* m_statstimer;
|
||||||
QTime m_statstimer_mark;
|
QTime m_statstimer_mark;
|
||||||
qint64 m_stats_tx_bytes_per_sec, m_stats_rx_bytes_per_sec;
|
qint64 m_stats_tx_bytes_per_sec, m_stats_rx_bytes_per_sec;
|
||||||
qint64 m_rx_bytes_last, m_tx_bytes_last;
|
qint64 m_rx_bytes_last, m_tx_bytes_last;
|
||||||
|
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
#include "databasecommand_collectionstats.h"
|
#include "databasecommand_collectionstats.h"
|
||||||
#include "dbsyncconnection.h"
|
#include "dbsyncconnection.h"
|
||||||
|
|
||||||
|
#define TCP_TIMEOUT 30
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
@@ -79,6 +81,7 @@ ControlConnection::setup()
|
|||||||
m_pingtimer->setInterval( 5000 );
|
m_pingtimer->setInterval( 5000 );
|
||||||
connect( m_pingtimer, SIGNAL( timeout() ), SLOT( onPingTimer() ) );
|
connect( m_pingtimer, SIGNAL( timeout() ), SLOT( onPingTimer() ) );
|
||||||
m_pingtimer->start();
|
m_pingtimer->start();
|
||||||
|
m_pingtimer_mark.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -171,25 +174,25 @@ ControlConnection::dbSyncConnection()
|
|||||||
void
|
void
|
||||||
ControlConnection::handleMsg( msg_ptr msg )
|
ControlConnection::handleMsg( msg_ptr msg )
|
||||||
{
|
{
|
||||||
// if small and not compresed, print it out for debug
|
|
||||||
if( msg->length() < 1024 && !msg->is( Msg::COMPRESSED ) )
|
|
||||||
{
|
|
||||||
qDebug() << id() << "got msg:" << QString::fromAscii( msg->payload() );
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << msg->flags();
|
|
||||||
if ( msg->is( Msg::PING ) )
|
if ( msg->is( Msg::PING ) )
|
||||||
{
|
{
|
||||||
qDebug() << "Received Connection PING, sending PONG.";
|
qDebug() << "Received Connection PING, sending PONG." << m_pingtimer_mark.elapsed();
|
||||||
sendMsg( Msg::factory( QByteArray(), Msg::PONG ) );
|
sendMsg( Msg::factory( QByteArray(), Msg::PONG ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( msg->is( Msg::PONG ) )
|
else if ( msg->is( Msg::PONG ) )
|
||||||
{
|
{
|
||||||
qDebug() << "Received Connection PONG, nice.";
|
qDebug() << "Received Connection PONG, nice.";
|
||||||
|
m_pingtimer_mark.restart();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if small and not compresed, print it out for debug
|
||||||
|
if( msg->length() < 1024 && !msg->is( Msg::COMPRESSED ) )
|
||||||
|
{
|
||||||
|
qDebug() << id() << "got msg:" << QString::fromAscii( msg->payload() );
|
||||||
|
}
|
||||||
|
|
||||||
// All control connection msgs are JSON
|
// All control connection msgs are JSON
|
||||||
if( !msg->is( Msg::JSON ) )
|
if( !msg->is( Msg::JSON ) )
|
||||||
{
|
{
|
||||||
@@ -235,5 +238,11 @@ void
|
|||||||
ControlConnection::onPingTimer()
|
ControlConnection::onPingTimer()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
if ( m_pingtimer_mark.elapsed() >= TCP_TIMEOUT * 1000 )
|
||||||
|
{
|
||||||
|
shutdown( false );
|
||||||
|
}
|
||||||
|
|
||||||
sendMsg( Msg::factory( QByteArray(), Msg::PING ) );
|
sendMsg( Msg::factory( QByteArray(), Msg::PING ) );
|
||||||
}
|
}
|
||||||
|
@@ -49,6 +49,7 @@ private:
|
|||||||
bool m_registered;
|
bool m_registered;
|
||||||
|
|
||||||
QTimer* m_pingtimer;
|
QTimer* m_pingtimer;
|
||||||
|
QTime m_pingtimer_mark;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLCONNECTION_H
|
#endif // CONTROLCONNECTION_H
|
||||||
|
Reference in New Issue
Block a user