Merge pull request #15036 from SimonWalton-HiFi/connect-class-in-nodelist-thread

Connection class should run in NodeList thread
This commit is contained in:
Shannon Romano 2019-03-04 12:30:24 -08:00 committed by GitHub
commit 29d5574d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -31,7 +31,6 @@ using namespace udt;
using namespace std::chrono;
Connection::Connection(Socket* parentSocket, HifiSockAddr destination, std::unique_ptr<CongestionControl> congestionControl) :
QObject(parentSocket),
_parentSocket(parentSocket),
_destination(destination),
_congestionControl(move(congestionControl))

View file

@ -251,7 +251,10 @@ Connection* Socket::findOrCreateConnection(const HifiSockAddr& sockAddr, bool fi
auto congestionControl = _ccFactory->create();
congestionControl->setMaxBandwidth(_maxBandwidth);
auto connection = std::unique_ptr<Connection>(new Connection(this, sockAddr, std::move(congestionControl)));
if (QThread::currentThread() != thread()) {
qCDebug(networking) << "Moving new Connection to NodeList thread";
connection->moveToThread(thread());
}
// allow higher-level classes to find out when connections have completed a handshake
QObject::connect(connection.get(), &Connection::receiverHandshakeRequestComplete,
this, &Socket::clientHandshakeRequestComplete);