HifiSockAddr have object names

This commit is contained in:
Atlante45 2015-07-29 17:28:37 -07:00
parent 116ff17fcf
commit b8085086c6
9 changed files with 36 additions and 9 deletions

View file

@ -95,6 +95,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
} }
_assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerPort, true); _assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerPort, true);
_assignmentServerSocket.setObjectName("AssigmentServer");
nodeList->setAssignmentServerSocket(_assignmentServerSocket); nodeList->setAssignmentServerSocket(_assignmentServerSocket);
qDebug() << "Assignment server socket is" << _assignmentServerSocket; qDebug() << "Assignment server socket is" << _assignmentServerSocket;
@ -119,6 +120,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
// did we get an assignment-client monitor port? // did we get an assignment-client monitor port?
if (assignmentMonitorPort > 0) { if (assignmentMonitorPort > 0) {
_assignmentClientMonitorSocket = HifiSockAddr(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME, assignmentMonitorPort); _assignmentClientMonitorSocket = HifiSockAddr(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME, assignmentMonitorPort);
_assignmentClientMonitorSocket.setObjectName("AssignmentClientMonitor");
qDebug() << "Assignment-client monitor socket is" << _assignmentClientMonitorSocket; qDebug() << "Assignment-client monitor socket is" << _assignmentClientMonitorSocket;

View file

@ -37,6 +37,8 @@ DomainHandler::DomainHandler(QObject* parent) :
_settingsObject(), _settingsObject(),
_failedSettingsRequests(0) _failedSettingsRequests(0)
{ {
_sockAddr.setObjectName("DomainServer");
// if we get a socket that make sure our NetworkPeer ping timer stops // if we get a socket that make sure our NetworkPeer ping timer stops
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer); connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
} }
@ -145,6 +147,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr; HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
replaceableSockAddr->~HifiSockAddr(); replaceableSockAddr->~HifiSockAddr();
replaceableSockAddr = new (replaceableSockAddr) HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT); replaceableSockAddr = new (replaceableSockAddr) HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
_iceServerSockAddr.setObjectName("IceServer");
auto nodeList = DependencyManager::get<NodeList>(); auto nodeList = DependencyManager::get<NodeList>();

View file

@ -33,16 +33,16 @@ HifiSockAddr::HifiSockAddr(const QHostAddress& address, quint16 port) :
} }
HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) : HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) :
QObject(),
_address(otherSockAddr._address), _address(otherSockAddr._address),
_port(otherSockAddr._port) _port(otherSockAddr._port)
{ {
setObjectName(otherSockAddr.objectName());
} }
HifiSockAddr& HifiSockAddr::operator=(const HifiSockAddr& rhsSockAddr) { HifiSockAddr& HifiSockAddr::operator=(const HifiSockAddr& rhsSockAddr) {
HifiSockAddr temp(rhsSockAddr); setObjectName(rhsSockAddr.objectName());
swap(temp); _address = rhsSockAddr._address;
_port = rhsSockAddr._port;
return *this; return *this;
} }
@ -76,9 +76,14 @@ HifiSockAddr::HifiSockAddr(const sockaddr* sockaddr) {
void HifiSockAddr::swap(HifiSockAddr& otherSockAddr) { void HifiSockAddr::swap(HifiSockAddr& otherSockAddr) {
using std::swap; using std::swap;
swap(_address, otherSockAddr._address); swap(_address, otherSockAddr._address);
swap(_port, otherSockAddr._port); swap(_port, otherSockAddr._port);
// Swap objects name
auto temp = otherSockAddr.objectName();
otherSockAddr.setObjectName(objectName());
setObjectName(temp);
} }
bool HifiSockAddr::operator==(const HifiSockAddr& rhsSockAddr) const { bool HifiSockAddr::operator==(const HifiSockAddr& rhsSockAddr) const {

View file

@ -57,7 +57,9 @@ void NetworkPeer::setPublicSocket(const HifiSockAddr& publicSocket) {
bool wasOldSocketNull = _publicSocket.isNull(); bool wasOldSocketNull = _publicSocket.isNull();
auto temp = _publicSocket.objectName();
_publicSocket = publicSocket; _publicSocket = publicSocket;
_publicSocket.setObjectName(temp);
if (!wasOldSocketNull) { if (!wasOldSocketNull) {
qCDebug(networking) << "Public socket change for node" << *this; qCDebug(networking) << "Public socket change for node" << *this;
@ -74,7 +76,9 @@ void NetworkPeer::setLocalSocket(const HifiSockAddr& localSocket) {
bool wasOldSocketNull = _localSocket.isNull(); bool wasOldSocketNull = _localSocket.isNull();
auto temp = _localSocket.objectName();
_localSocket = localSocket; _localSocket = localSocket;
_localSocket.setObjectName(temp);
if (!wasOldSocketNull) { if (!wasOldSocketNull) {
qCDebug(networking) << "Local socket change for node" << *this; qCDebug(networking) << "Local socket change for node" << *this;
@ -91,7 +95,9 @@ void NetworkPeer::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
bool wasOldSocketNull = _symmetricSocket.isNull(); bool wasOldSocketNull = _symmetricSocket.isNull();
auto temp = _symmetricSocket.objectName();
_symmetricSocket = symmetricSocket; _symmetricSocket = symmetricSocket;
_symmetricSocket.setObjectName(temp);
if (!wasOldSocketNull) { if (!wasOldSocketNull) {
qCDebug(networking) << "Symmetric socket change for node" << *this; qCDebug(networking) << "Symmetric socket change for node" << *this;

View file

@ -55,13 +55,23 @@ Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
_canAdjustLocks(canAdjustLocks), _canAdjustLocks(canAdjustLocks),
_canRez(canRez) _canRez(canRez)
{ {
// Update socket's object name
setType(_type);
} }
Node::~Node() { Node::~Node() {
delete _linkedData; delete _linkedData;
} }
void Node::setType(char type) {
_type = type;
auto typeString = NodeType::getNodeTypeName(type);
_publicSocket.setObjectName(typeString);
_localSocket.setObjectName(typeString);
_symmetricSocket.setObjectName(typeString);
}
void Node::updateClockSkewUsec(int clockSkewSample) { void Node::updateClockSkewUsec(int clockSkewSample) {
_clockSkewMovingPercentile.updatePercentile((float)clockSkewSample); _clockSkewMovingPercentile.updatePercentile((float)clockSkewSample);
_clockSkewUsec = (int)_clockSkewMovingPercentile.getValueAtPercentile(); _clockSkewUsec = (int)_clockSkewMovingPercentile.getValueAtPercentile();

View file

@ -40,7 +40,7 @@ public:
bool operator!=(const Node& otherNode) const { return !(*this == otherNode); } bool operator!=(const Node& otherNode) const { return !(*this == otherNode); }
char getType() const { return _type; } char getType() const { return _type; }
void setType(char type) { _type = type; } void setType(char type);
const QUuid& getConnectionSecret() const { return _connectionSecret; } const QUuid& getConnectionSecret() const { return _connectionSecret; }
void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; } void setConnectionSecret(const QUuid& connectionSecret) { _connectionSecret = connectionSecret; }

View file

@ -30,7 +30,7 @@ std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr dest)
// Setup queue private thread // Setup queue private thread
QThread* thread = new QThread(); QThread* thread = new QThread();
thread->setObjectName("Networking: SendQueue"); // Name thread for easier debug thread->setObjectName("Networking: SendQueue " + dest.objectName()); // Name thread for easier debug
connect(queue.get(), &QObject::destroyed, thread, &QThread::quit); // Thread auto cleanup connect(queue.get(), &QObject::destroyed, thread, &QThread::quit); // Thread auto cleanup
connect(thread, &QThread::finished, thread, &QThread::deleteLater); // Thread auto cleanup connect(thread, &QThread::finished, thread, &QThread::deleteLater); // Thread auto cleanup

View file

@ -14,6 +14,7 @@
#include <QtCore/QThread> #include <QtCore/QThread>
#include "../NetworkLogging.h" #include "../NetworkLogging.h"
#include "Connection.h"
#include "ControlPacket.h" #include "ControlPacket.h"
#include "Packet.h" #include "Packet.h"

View file

@ -23,11 +23,11 @@
#include "../HifiSockAddr.h" #include "../HifiSockAddr.h"
#include "CongestionControl.h" #include "CongestionControl.h"
#include "Connection.h"
namespace udt { namespace udt {
class BasePacket; class BasePacket;
class Connection;
class ControlSender; class ControlSender;
class Packet; class Packet;
class SequenceNumber; class SequenceNumber;