mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +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 int BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
static const unsigned long MAX_SIZE = 50 * 1024 * BYTES_PER_MEGABYTES; // 50 GB (Virtually remove limit)
|
||||
static const long long BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||
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 TIMEOUT = 1000;
|
||||
static const int MAX_CHECK = 30;
|
||||
|
|
|
@ -353,7 +353,7 @@ void DatagramSequencer::sendRecordLost(const SendRecord& record) {
|
|||
if (_packetDropCount == 0 || record.packetNumber == _lastPacketDropped + 1) {
|
||||
_packetDropCount++;
|
||||
_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) {
|
||||
_packetsPerGroup = qMax(_packetsPerGroup * 0.5f, 1.0f);
|
||||
_slowStartThreshold = _packetsPerGroup;
|
||||
|
|
|
@ -147,28 +147,21 @@ QUdpSocket& LimitedNodeList::getDTLSSocket() {
|
|||
}
|
||||
|
||||
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++) {
|
||||
int bufferOpt = (i == 0) ? SO_SNDBUF : SO_RCVBUF;
|
||||
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&oldBufferSize), &sizeOfInt);
|
||||
|
||||
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<const char*>(&numBytes),
|
||||
sizeof(numBytes));
|
||||
|
||||
QString bufferTypeString = (i == 0) ? "send" : "receive";
|
||||
|
||||
QAbstractSocket::SocketOption bufferOpt;
|
||||
QString bufferTypeString;
|
||||
if (i == 0) {
|
||||
bufferOpt = QAbstractSocket::SendBufferSizeSocketOption;
|
||||
bufferTypeString = "send";
|
||||
|
||||
} else {
|
||||
bufferOpt = QAbstractSocket::ReceiveBufferSizeSocketOption;
|
||||
bufferTypeString = "receive";
|
||||
}
|
||||
int oldBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||
if (oldBufferSize < numBytes) {
|
||||
int newBufferSize = 0;
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
||||
_nodeSocket.setSocketOption(bufferOpt, numBytes);
|
||||
int newBufferSize = _nodeSocket.socketOption(bufferOpt).toInt();
|
||||
|
||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
||||
<< newBufferSize << "bytes";
|
||||
|
|
Loading…
Reference in a new issue