mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Set TCP KEEPALIVE values to detect dead sources.
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
|
||||||
#include "servent.h"
|
#include "servent.h"
|
||||||
|
|
||||||
#define PROTOVER "2" // must match remote peer, or we can't talk.
|
#define PROTOVER "2" // must match remote peer, or we can't talk.
|
||||||
@@ -210,6 +213,15 @@ Connection::doSetup()
|
|||||||
m_statstimer->start();
|
m_statstimer->start();
|
||||||
m_statstimer_mark.start();
|
m_statstimer_mark.start();
|
||||||
|
|
||||||
|
m_sock->setSocketOption( QAbstractSocket::KeepAliveOption, 1 );
|
||||||
|
int sockID = m_sock.data()->socketDescriptor();
|
||||||
|
int idle = 30;
|
||||||
|
int intvl = 5;
|
||||||
|
int cnt = 3;
|
||||||
|
setsockopt( sockID, SOL_TCP, TCP_KEEPIDLE, &idle, sizeof( idle ) );
|
||||||
|
setsockopt( sockID, SOL_TCP, TCP_KEEPINTVL, &intvl, sizeof( intvl ) );
|
||||||
|
setsockopt( sockID, SOL_TCP, TCP_KEEPCNT, &cnt, sizeof( cnt ) );
|
||||||
|
|
||||||
m_sock->moveToThread( thread() );
|
m_sock->moveToThread( thread() );
|
||||||
|
|
||||||
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
qsrand( QTime( 0, 0, 0 ).secsTo( QTime::currentTime() ) );
|
||||||
@@ -248,7 +260,7 @@ Connection::doSetup()
|
|||||||
void
|
void
|
||||||
Connection::socketDisconnected()
|
Connection::socketDisconnected()
|
||||||
{
|
{
|
||||||
qDebug() << "SOCKET DISCONNECTED" << this->name()
|
qDebug() << "SOCKET DISCONNECTED" << this->name() << id()
|
||||||
<< "shutdown will happen after incoming queue empties."
|
<< "shutdown will happen after incoming queue empties."
|
||||||
<< "bytesavail:" << m_sock->bytesAvailable()
|
<< "bytesavail:" << m_sock->bytesAvailable()
|
||||||
<< "bytesRecvd" << bytesReceived();
|
<< "bytesRecvd" << bytesReceived();
|
||||||
|
@@ -270,6 +270,7 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< QList<QString> >("QList<QString>");
|
qRegisterMetaType< QList<QString> >("QList<QString>");
|
||||||
qRegisterMetaType< Connection* >("Connection*");
|
qRegisterMetaType< Connection* >("Connection*");
|
||||||
qRegisterMetaType< QAbstractSocket::SocketError >("QAbstractSocket::SocketError");
|
qRegisterMetaType< QAbstractSocket::SocketError >("QAbstractSocket::SocketError");
|
||||||
|
qRegisterMetaType< QTcpSocket* >("QTcpSocket*");
|
||||||
qRegisterMetaType< QSharedPointer<QIODevice> >("QSharedPointer<QIODevice>");
|
qRegisterMetaType< QSharedPointer<QIODevice> >("QSharedPointer<QIODevice>");
|
||||||
qRegisterMetaType< QFileInfo >("QFileInfo");
|
qRegisterMetaType< QFileInfo >("QFileInfo");
|
||||||
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
qRegisterMetaType< QMap<QString, unsigned int> >("QMap<QString, unsigned int>");
|
||||||
@@ -289,11 +290,8 @@ TomahawkApp::registerMetaTypes()
|
|||||||
qRegisterMetaType< QMap< QString, Tomahawk::plentry_ptr > >("QMap< QString, Tomahawk::plentry_ptr >");
|
qRegisterMetaType< QMap< QString, Tomahawk::plentry_ptr > >("QMap< QString, Tomahawk::plentry_ptr >");
|
||||||
qRegisterMetaType< Tomahawk::PlaylistRevision >("Tomahawk::PlaylistRevision");
|
qRegisterMetaType< Tomahawk::PlaylistRevision >("Tomahawk::PlaylistRevision");
|
||||||
qRegisterMetaType< Tomahawk::QID >("Tomahawk::QID");
|
qRegisterMetaType< Tomahawk::QID >("Tomahawk::QID");
|
||||||
qRegisterMetaType< QTcpSocket* >("QTcpSocket*");
|
|
||||||
|
|
||||||
#ifndef TOMAHAWK_HEADLESS
|
|
||||||
qRegisterMetaType< AudioErrorCode >("AudioErrorCode");
|
qRegisterMetaType< AudioErrorCode >("AudioErrorCode");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user