From 499e748d54b062f20ef6b893c00aa645db9a316f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 6 Oct 2014 13:45:11 -0700 Subject: [PATCH] rebind the node socket when switching to ThreadedAssignment --- libraries/networking/src/LimitedNodeList.cpp | 7 +++++++ libraries/networking/src/LimitedNodeList.h | 2 ++ libraries/networking/src/ThreadedAssignment.cpp | 3 +++ 3 files changed, 12 insertions(+) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 507788009a..0279c9b697 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -576,6 +576,13 @@ void LimitedNodeList::sendSTUNRequest() { stunSockAddr.getAddress(), stunSockAddr.getPort()); } +void LimitedNodeList::rebindNodeSocket() { + quint16 oldPort = _nodeSocket.localPort(); + + _nodeSocket.close(); + _nodeSocket.bind(QHostAddress::AnyIPv4, oldPort); +} + bool LimitedNodeList::processSTUNResponse(const QByteArray& packet) { // check the cookie to make sure this is actually a STUN response // and read the first attribute and make sure it is a XOR_MAPPED_ADDRESS diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index a7ffc7ec28..406b851d0e 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -69,6 +69,8 @@ public: const QUuid& getSessionUUID() const { return _sessionUUID; } void setSessionUUID(const QUuid& sessionUUID); + + void rebindNodeSocket(); QUdpSocket& getNodeSocket() { return _nodeSocket; } QUdpSocket& getDTLSSocket(); diff --git a/libraries/networking/src/ThreadedAssignment.cpp b/libraries/networking/src/ThreadedAssignment.cpp index cd80c441c1..6d2e366499 100644 --- a/libraries/networking/src/ThreadedAssignment.cpp +++ b/libraries/networking/src/ThreadedAssignment.cpp @@ -59,6 +59,9 @@ void ThreadedAssignment::commonInit(const QString& targetName, NodeType_t nodeTy NodeList* nodeList = NodeList::getInstance(); nodeList->setOwnerType(nodeType); + // this is a temp fix for Qt 5.3 - rebinding the node socket gives us readyRead for the socket on this thread + nodeList->rebindNodeSocket(); + QTimer* domainServerTimer = new QTimer(this); connect(domainServerTimer, SIGNAL(timeout()), this, SLOT(checkInWithDomainServerOrExit())); domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);