From c9b3b5ff7d523b7b26b6b4aab6c16eb09e4c165d Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Dec 2014 12:30:38 -0800 Subject: [PATCH 1/2] Scale back on first dropped packet, use Qt send/receive buffer size options rather than setsockopt/getsockopt. --- .../metavoxels/src/DatagramSequencer.cpp | 2 +- libraries/networking/src/LimitedNodeList.cpp | 33 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/libraries/metavoxels/src/DatagramSequencer.cpp b/libraries/metavoxels/src/DatagramSequencer.cpp index 65d548ba1c..e236ffd217 100644 --- a/libraries/metavoxels/src/DatagramSequencer.cpp +++ b/libraries/metavoxels/src/DatagramSequencer.cpp @@ -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; diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 5e13f6bbc9..b0c2defd9b 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -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(&oldBufferSize), &sizeOfInt); - - setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast(&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(&newBufferSize), &sizeOfInt); + _nodeSocket.setSocketOption(bufferOpt, numBytes); + int newBufferSize = _nodeSocket.socketOption(bufferOpt).toInt(); qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to" << newBufferSize << "bytes"; From 0d07875f94ff51685bb4a33d13a1f22e90b349b6 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Dec 2014 12:54:12 -0800 Subject: [PATCH 2/2] Fix overflow warning. --- interface/src/ModelUploader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/ModelUploader.cpp b/interface/src/ModelUploader.cpp index e702d9db76..89b6a4c9c0 100644 --- a/interface/src/ModelUploader.cpp +++ b/interface/src/ModelUploader.cpp @@ -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;