Merge pull request #15677 from roxanneskelly/bugz516

Log socket error string when socket error happens
This commit is contained in:
Roxanne Skelly 2019-06-05 15:50:15 -07:00 committed by GitHub
commit b8d6c57483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 4 deletions

View file

@ -437,7 +437,18 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiS
return size;
} else {
return sendUnreliablePacket(*packet, sockAddr, hmacAuth);
auto size = sendUnreliablePacket(*packet, sockAddr, hmacAuth);
if (size < 0) {
auto now = usecTimestampNow();
eachNode([now](const SharedNodePointer & node) {
qCDebug(networking) << "Stats for " << node->getPublicSocket() << "\n"
<< " Last Heard Microstamp: " << node->getLastHeardMicrostamp() << " (" << (now - node->getLastHeardMicrostamp()) << "usec ago)\n"
<< " Outbound Kbps: " << node->getOutboundKbps() << "\n"
<< " Inbound Kbps: " << node->getInboundKbps() << "\n"
<< " Ping: " << node->getPingMs();
});
}
return size;
}
}

View file

@ -226,8 +226,17 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc
qint64 bytesWritten = _udpSocket.writeDatagram(datagram, sockAddr.getAddress(), sockAddr.getPort());
if (bytesWritten < 0) {
// when saturating a link this isn't an uncommon message - suppress it so it doesn't bomb the debug
qCDebug(networking) << "Socket::writeDatagram : " << sockAddr << " " << _udpSocket.error();
qCDebug(networking) << "udt::writeDatagram (" << _udpSocket.state() << ") error - " << _udpSocket.error() << "(" << _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;
#endif // DEBUG_EVENT_QUEUE
}
return bytesWritten;
@ -490,7 +499,11 @@ std::vector<HifiSockAddr> Socket::getConnectionSockAddrs() {
}
void Socket::handleSocketError(QAbstractSocket::SocketError socketError) {
qCDebug(networking) << "udt::Socket error - " << socketError;
qCDebug(networking) << "udt::Socket (" << _udpSocket.state() << ") error - " << socketError << "(" << _udpSocket.errorString() << ")";
#ifdef DEBUG_EVENT_QUEUE
int nodeListQueueSize = ::hifi::qt::getEventQueueSize(thread());
qCDebug(networking) << "Networking queue size - " << nodeListQueueSize;
#endif // DEBUG_EVENT_QUEUE
}
void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) {