From b753871fc11c5b27e03b9fb44c67748a6641e10b Mon Sep 17 00:00:00 2001
From: Stephen Birarda <commit@birarda.com>
Date: Tue, 25 Oct 2016 11:20:10 -0700
Subject: [PATCH] don't change DF or buffer sizes for ice-server

---
 ice-server/src/IceServer.cpp            |  2 +-
 libraries/networking/src/udt/Socket.cpp | 22 +++++++++++++---------
 libraries/networking/src/udt/Socket.h   |  4 +++-
 3 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/ice-server/src/IceServer.cpp b/ice-server/src/IceServer.cpp
index 3f229d2f87..f8bf1f62ae 100644
--- a/ice-server/src/IceServer.cpp
+++ b/ice-server/src/IceServer.cpp
@@ -30,7 +30,7 @@ const int PEER_SILENCE_THRESHOLD_MSECS = 5 * 1000;
 IceServer::IceServer(int argc, char* argv[]) :
     QCoreApplication(argc, argv),
     _id(QUuid::createUuid()),
-    _serverSocket(),
+    _serverSocket(0, false),
     _activePeers()
 {
     // start the ice-server socket
diff --git a/libraries/networking/src/udt/Socket.cpp b/libraries/networking/src/udt/Socket.cpp
index 6dddf50e0a..7ddbd54593 100644
--- a/libraries/networking/src/udt/Socket.cpp
+++ b/libraries/networking/src/udt/Socket.cpp
@@ -29,9 +29,10 @@
 
 using namespace udt;
 
-Socket::Socket(QObject* parent) :
+Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
     QObject(parent),
-    _synTimer(new QTimer(this))
+    _synTimer(new QTimer(this)),
+    _shouldChangeSocketOptions(shouldChangeSocketOptions)
 {
     connect(&_udpSocket, &QUdpSocket::readyRead, this, &Socket::readPendingDatagrams);
 
@@ -49,17 +50,20 @@ Socket::Socket(QObject* parent) :
 
 void Socket::bind(const QHostAddress& address, quint16 port) {
     _udpSocket.bind(address, port);
-    setSystemBufferSizes();
+
+    if (_shouldChangeSocketOptions) {
+        setSystemBufferSizes();
 
 #if defined(Q_OS_LINUX)
-    auto sd = _udpSocket.socketDescriptor();
-    int val = IP_PMTUDISC_DONT;
-    setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
+        auto sd = _udpSocket.socketDescriptor();
+        int val = IP_PMTUDISC_DONT;
+        setsockopt(sd, IPPROTO_IP, IP_MTU_DISCOVER, &val, sizeof(val));
 #elif defined(Q_OS_WINDOWS)
-    auto sd = _udpSocket.socketDescriptor();
-    int val = 0; // false
-    setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, &val, sizeof(val));
+        auto sd = _udpSocket.socketDescriptor();
+        int val = 0; // false
+        setsockopt(sd, IPPROTO_IP, IP_DONTFRAGMENT, &val, sizeof(val));
 #endif
+    }
 }
 
 void Socket::rebind() {
diff --git a/libraries/networking/src/udt/Socket.h b/libraries/networking/src/udt/Socket.h
index 2a6d119b64..d65cb1406c 100644
--- a/libraries/networking/src/udt/Socket.h
+++ b/libraries/networking/src/udt/Socket.h
@@ -54,7 +54,7 @@ class Socket : public QObject {
 public:
     using StatsVector = std::vector<std::pair<HifiSockAddr, ConnectionStats::Stats>>;
     
-    Socket(QObject* object = 0);
+    Socket(QObject* object = 0, bool shouldChangeSocketOptions = true);
     
     quint16 localPort() const { return _udpSocket.localPort(); }
     
@@ -139,6 +139,8 @@ private:
     int _maxBandwidth { -1 };
 
     std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<TCPVegasCC>() };
+
+    bool _shouldChangeSocketOptions { true };
     
     friend UDTTest;
 };