mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:00:41 +02:00
Merge pull request #4017 from ey6es/master
Scale back on first dropped packet, use Qt socket options, fixed overflow warning.
This commit is contained in:
commit
58c95a12aa
3 changed files with 16 additions and 23 deletions
|
@ -55,8 +55,8 @@ static const QString MODEL_URL = "/api/v1/models";
|
||||||
|
|
||||||
static const QString SETTING_NAME = "LastModelUploadLocation";
|
static const QString SETTING_NAME = "LastModelUploadLocation";
|
||||||
|
|
||||||
static const int BYTES_PER_MEGABYTES = 1024 * 1024;
|
static const long long BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||||
static const unsigned long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
static const unsigned long long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
||||||
static const int MAX_TEXTURE_SIZE = 1024;
|
static const int MAX_TEXTURE_SIZE = 1024;
|
||||||
static const int TIMEOUT = 1000;
|
static const int TIMEOUT = 1000;
|
||||||
static const int MAX_CHECK = 30;
|
static const int MAX_CHECK = 30;
|
||||||
|
|
|
@ -353,7 +353,7 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) {
|
||||||
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
||||||
_packetDropCount++;
|
_packetDropCount++;
|
||||||
_lastPacketDropped = record.packetNumber;
|
_lastPacketDropped = record.packetNumber;
|
||||||
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 3;
|
const int CONSECUTIVE_DROPS_BEFORE_REDUCTION = 1;
|
||||||
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
|
if (_packetDropCount >= CONSECUTIVE_DROPS_BEFORE_REDUCTION && record.packetNumber >= _packetRateDecreasePacketNumber) {
|
||||||
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
||||||
_slowStartThreshold = _packetsPerGroup;
|
_slowStartThreshold = _packetsPerGroup;
|
||||||
|
|
|
@ -147,28 +147,21 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
||||||
// change the socket send buffer size to be 1MB
|
|
||||||
int oldBufferSize = 0;
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
int sizeOfInt = sizeof(oldBufferSize);
|
|
||||||
#else
|
|
||||||
unsigned int sizeOfInt = sizeof(oldBufferSize);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
int bufferOpt = (i == 0) ? SO_SNDBUF : SO_RCVBUF;
|
QAbstractSocket::SocketOption bufferOpt;
|
||||||
|
QString bufferTypeString;
|
||||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&oldBufferSize), &sizeOfInt);
|
if (i == 0) {
|
||||||
|
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
||||||
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<const char*>(&numBytes),
|
bufferTypeString = "send";
|
||||||
sizeof(numBytes));
|
|
||||||
|
} else {
|
||||||
QString bufferTypeString = (i == 0) ? "send" : "receive";
|
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
||||||
|
bufferTypeString = "receive";
|
||||||
|
}
|
||||||
|
int oldBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||||
if (oldBufferSize < numBytes) {
|
if (oldBufferSize < numBytes) {
|
||||||
int newBufferSize = 0;
|
_nodeSocket.setSocketOption(bufferOpt, numBytes);
|
||||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
int newBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||||
|
|
||||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
||||||
<< newBufferSize << "bytes";
|
<< newBufferSize << "bytes";
|
||||||
|
|
Loading…
Reference in a new issue