mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 23:09:52 +02:00
Reset NodeList upon local nework change; abort current socket when rebinding
Also ensure QUdpSocket is owned by LimitedNodeList.
This commit is contained in:
parent
aa65361b37
commit
d780964cb4
2 changed files with 4 additions and 2 deletions
|
@ -1239,6 +1239,7 @@ void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
|
||||||
} else {
|
} else {
|
||||||
qCInfo(networking) << "Local socket has changed from" << _localSockAddr << "to" << sockAddr;
|
qCInfo(networking) << "Local socket has changed from" << _localSockAddr << "to" << sockAddr;
|
||||||
if (_hasTCPCheckedLocalSocket) { // Force a port change for NAT:
|
if (_hasTCPCheckedLocalSocket) { // Force a port change for NAT:
|
||||||
|
reset();
|
||||||
_nodeSocket.rebind(0);
|
_nodeSocket.rebind(0);
|
||||||
_localSockAddr.setPort(_nodeSocket.localPort());
|
_localSockAddr.setPort(_nodeSocket.localPort());
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ using namespace udt;
|
||||||
|
|
||||||
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
_udpSocket(parent),
|
||||||
_readyReadBackupTimer(new QTimer(this)),
|
_readyReadBackupTimer(new QTimer(this)),
|
||||||
_shouldChangeSocketOptions(shouldChangeSocketOptions)
|
_shouldChangeSocketOptions(shouldChangeSocketOptions)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +51,7 @@ Socket::Socket(QObject* parent, bool shouldChangeSocketOptions) :
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::bind(const QHostAddress& address, quint16 port) {
|
void Socket::bind(const QHostAddress& address, quint16 port) {
|
||||||
|
|
||||||
_udpSocket.bind(address, port);
|
_udpSocket.bind(address, port);
|
||||||
|
|
||||||
if (_shouldChangeSocketOptions) {
|
if (_shouldChangeSocketOptions) {
|
||||||
|
@ -72,8 +74,7 @@ void Socket::rebind() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Socket::rebind(quint16 localPort) {
|
void Socket::rebind(quint16 localPort) {
|
||||||
_udpSocket.close();
|
_udpSocket.abort();
|
||||||
_udpSocket.waitForDisconnected();
|
|
||||||
bind(QHostAddress::AnyIPv4, localPort);
|
bind(QHostAddress::AnyIPv4, localPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue