mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
don't change the socket buffer sizes if it is already larger
This commit is contained in:
parent
ec260dbab2
commit
64c11ebf8f
1 changed files with 14 additions and 5 deletions
|
@ -82,7 +82,7 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
|
|||
qDebug() << "NodeList DTLS socket is listening on" << _dtlsSocket->localPort();
|
||||
}
|
||||
|
||||
const int LARGER_BUFFER_SIZE = 1048576;
|
||||
const int LARGER_BUFFER_SIZE = 2097152;
|
||||
changeSocketBufferSizes(LARGER_BUFFER_SIZE);
|
||||
|
||||
_packetStatTimer.start();
|
||||
|
@ -147,12 +147,21 @@ void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
|||
setsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<const char*>(&numBytes),
|
||||
sizeof(numBytes));
|
||||
|
||||
int newBufferSize = 0;
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
||||
|
||||
QString bufferTypeString = (i == 0) ? "send" : "receive";
|
||||
|
||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to" << newBufferSize << "bytes";
|
||||
if (oldBufferSize < numBytes) {
|
||||
int newBufferSize = 0;
|
||||
getsockopt(_nodeSocket.socketDescriptor(), SOL_SOCKET, bufferOpt, reinterpret_cast<char*>(&newBufferSize), &sizeOfInt);
|
||||
|
||||
qDebug() << "Changed socket" << bufferTypeString << "buffer size from" << oldBufferSize << "to"
|
||||
<< newBufferSize << "bytes";
|
||||
} else {
|
||||
// don't make the buffer smaller
|
||||
qDebug() << "Did not change socket" << bufferTypeString << "buffer size from" << oldBufferSize
|
||||
<< "since it is larger than desired size of" << numBytes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue