Merge pull request #15694 from roxanneskelly/bugz516

BUGZ-516 - attempt to rebind bound sockets on silent domain checkin
This commit is contained in:
Roxanne Skelly 2019-06-10 12:30:23 -07:00 committed by GitHub
commit 4a89d22482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View file

@ -438,7 +438,13 @@ void NodeList::sendDomainServerCheckIn() {
// Send duplicate check-ins in the exponentially increasing sequence 1, 1, 2, 4, ...
static const int MAX_CHECKINS_TOGETHER = 20;
static const int REBIND_CHECKIN_COUNT = 2;
int outstandingCheckins = _domainHandler.getCheckInPacketsSinceLastReply();
if (outstandingCheckins > REBIND_CHECKIN_COUNT) {
_nodeSocket.rebind();
}
int checkinCount = outstandingCheckins > 1 ? std::pow(2, outstandingCheckins - 2) : 1;
checkinCount = std::min(checkinCount, MAX_CHECKINS_TOGETHER);
for (int i = 1; i < checkinCount; ++i) {
@ -673,13 +679,6 @@ void NodeList::processDomainServerList(QSharedPointer<ReceivedMessage> message)
// refuse to process this packet if we aren't currently connected to the DS
return;
}
#ifdef DEBUG_EVENT_QUEUE
{
int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread());
qCDebug(networking) << "DomainList received, pending count =" << _domainHandler.getCheckInPacketsSinceLastReply()
<< "NodeList thread event queue size =" << nodeListQueueSize;
}
#endif
// warn if ping lag is getting long
if (pingLagTime > qint64(MSECS_PER_SECOND)) {

View file

@ -223,6 +223,13 @@ qint64 Socket::writeDatagram(const char* data, qint64 size, const HifiSockAddr&
qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr) {
// don't attempt to write the datagram if we're unbound. Just drop it.
// _udpSocket.writeDatagram will return an error anyway, but there are
// potential crashes in Qt when that happens.
if (_udpSocket.state() != QAbstractSocket::BoundState) {
qCDebug(networking) << "Attempt to writeDatagram when in unbound state";
return -1;
}
qint64 bytesWritten = _udpSocket.writeDatagram(datagram, sockAddr.getAddress(), sockAddr.getPort());
if (bytesWritten < 0) {
@ -500,6 +507,10 @@ std::vector<HifiSockAddr> Socket::getConnectionSockAddrs() {
void Socket::handleSocketError(QAbstractSocket::SocketError socketError) {
qCDebug(networking) << "udt::Socket (" << _udpSocket.state() << ") error - " << socketError << "(" << _udpSocket.errorString() << ")";
#ifdef WIN32
int wsaError = WSAGetLastError();
qCDebug(networking) << "windows socket error " << wsaError;
#endif
#ifdef DEBUG_EVENT_QUEUE
int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread());
qCDebug(networking) << "Networking queue size - " << nodeListQueueSize;