mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 23:36:41 +02:00
Merge pull request #8925 from birarda/master
add a timer to Socket to check for readyRead backup
This commit is contained in:
commit
8565f870e9
2 changed files with 25 additions and 0 deletions
|
@ -32,6 +32,7 @@ using namespace udt;
|
||||||
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
_synTimer(new QTimer(this)),
|
_synTimer(new QTimer(this)),
|
||||||
|
_readyReadBackupTimer(new QTimer(this)),
|
||||||
_shouldChangeSocketOptions(shouldChangeSocketOptions)
|
_shouldChangeSocketOptions(shouldChangeSocketOptions)
|
||||||
{
|
{
|
||||||
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
|
||||||
|
@ -46,6 +47,11 @@ Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
||||||
connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
|
connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
|
||||||
this, SLOT(handleSocketError(QAbstractSocket::SocketError)));
|
this, SLOT(handleSocketError(QAbstractSocket::SocketError)));
|
||||||
connect(&_udpSocket, &QAbstractSocket::stateChanged, this, &Socket::handleStateChanged);
|
connect(&_udpSocket, &QAbstractSocket::stateChanged, this, &Socket::handleStateChanged);
|
||||||
|
|
||||||
|
// in order to help track down the zombie server bug, add a timer to check if we missed a readyRead
|
||||||
|
const int READY_READ_BACKUP_CHECK_MSECS = 10 * 1000;
|
||||||
|
connect(_readyReadBackupTimer, &QTimer::timeout, this, &Socket::checkForReadyReadBackup);
|
||||||
|
_readyReadBackupTimer->start(READY_READ_BACKUP_CHECK_MSECS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::bind(const QHostAddress& address, quint16 port) {
|
void Socket::bind(const QHostAddress& address, quint16 port) {
|
||||||
|
@ -296,9 +302,25 @@ void Socket::messageFailed(Connection* connection, Packet::MessageNumber message
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Socket::checkForReadyReadBackup() {
|
||||||
|
if (_udpSocket.hasPendingDatagrams()) {
|
||||||
|
qCDebug(networking) << "Socket::checkForReadyReadBackup() detected blocked readyRead signal. Flushing pending datagrams.";
|
||||||
|
|
||||||
|
// drop all of the pending datagrams on the floor
|
||||||
|
while (_udpSocket.hasPendingDatagrams()) {
|
||||||
|
_udpSocket.readDatagram(nullptr, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Socket::readPendingDatagrams() {
|
void Socket::readPendingDatagrams() {
|
||||||
int packetSizeWithHeader = -1;
|
int packetSizeWithHeader = -1;
|
||||||
|
|
||||||
while ((packetSizeWithHeader = _udpSocket.pendingDatagramSize()) != -1) {
|
while ((packetSizeWithHeader = _udpSocket.pendingDatagramSize()) != -1) {
|
||||||
|
|
||||||
|
// we're reading a packet so re-start the readyRead backup timer
|
||||||
|
_readyReadBackupTimer->start();
|
||||||
|
|
||||||
// grab a time point we can mark as the receive time of this packet
|
// grab a time point we can mark as the receive time of this packet
|
||||||
auto receiveTime = p_high_resolution_clock::now();
|
auto receiveTime = p_high_resolution_clock::now();
|
||||||
|
|
||||||
|
|
|
@ -101,6 +101,7 @@ public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
|
void checkForReadyReadBackup();
|
||||||
void rateControlSync();
|
void rateControlSync();
|
||||||
|
|
||||||
void handleSocketError(QAbstractSocket::SocketError socketError);
|
void handleSocketError(QAbstractSocket::SocketError socketError);
|
||||||
|
@ -136,6 +137,8 @@ private:
|
||||||
int _synInterval { 10 }; // 10ms
|
int _synInterval { 10 }; // 10ms
|
||||||
QTimer* _synTimer { nullptr };
|
QTimer* _synTimer { nullptr };
|
||||||
|
|
||||||
|
QTimer* _readyReadBackupTimer { nullptr };
|
||||||
|
|
||||||
int _maxBandwidth { -1 };
|
int _maxBandwidth { -1 };
|
||||||
|
|
||||||
std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<TCPVegasCC>() };
|
std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<TCPVegasCC>() };
|
||||||
|
|
Loading…
Reference in a new issue