debugging

This commit is contained in:
ZappoMan 2017-11-17 08:55:55 -08:00
parent e438ac54d5
commit cd0fa989e1
11 changed files with 105 additions and 18 deletions

View file

@ -41,7 +41,8 @@ EntityServer::EntityServer(ReceivedMessage& message) :
DependencyManager::set<ScriptCache>();
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver();
packetReceiver.registerListenerForTypes({ PacketType::EntityAdd,
packetReceiver.registerListenerForTypes({
//PacketType::EntityAdd,
PacketType::EntityEdit,
PacketType::EntityErase,
PacketType::EntityPhysics,
@ -51,6 +52,9 @@ EntityServer::EntityServer(ReceivedMessage& message) :
this,
"handleEntityPacket");
packetReceiver.registerListener(PacketType::EntityAdd, this, "handleEntityPacket");
connect(&_dynamicDomainVerificationTimer, &QTimer::timeout, this, &EntityServer::startDynamicDomainVerification);
_dynamicDomainVerificationTimer.setSingleShot(true);
}
@ -72,7 +76,13 @@ void EntityServer::aboutToFinish() {
}
void EntityServer::handleEntityPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
qDebug() << __FUNCTION__ << "from:" << senderNode->getUUID() << "type:" << message->getType();
qDebug() << __FUNCTION__ << "from:" << senderNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
if (_octreeInboundPacketProcessor) {
_octreeInboundPacketProcessor->queueReceivedPacket(message, senderNode);
}

View file

@ -77,7 +77,12 @@ void OctreeInboundPacketProcessor::midProcess() {
void OctreeInboundPacketProcessor::processPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType();
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
if (_shuttingDown) {
qDebug() << "OctreeInboundPacketProcessor::processPacket() while shutting down... ignoring incoming packet";

View file

@ -81,6 +81,9 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
EntityTreePointer entityTree,
EntityItemID entityItemID,
const EntityItemProperties& properties) {
qDebug() << __FUNCTION__ << "type:" << type;
if (!_shouldSend) {
return; // bail early
}
@ -93,6 +96,14 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
QByteArray bufferOut(NLPacket::maxPayloadSize(type), 0);
if (type == PacketType::EntityAdd) {
auto MAX_ADD_DATA_SIZE = NLPacket::maxPayloadSize(type) * 10; // a really big packet
bufferOut.resize(MAX_ADD_DATA_SIZE);
}
qDebug() << __FUNCTION__ << "bufferOut.size():" << bufferOut.size();
OctreeElement::AppendState encodeResult = OctreeElement::PARTIAL; // start the loop assuming there's more to send
auto nodeList = DependencyManager::get<NodeList>();
@ -115,6 +126,9 @@ void EntityEditPacketSender::queueEditEntityMessage(PacketType type,
qCDebug(entities) << " id:" << entityItemID;
qCDebug(entities) << " properties:" << properties;
#endif
qDebug() << __FUNCTION__ << "about to call queueOctreeEditMessage() --- bufferOut.size():" << bufferOut.size();
queueOctreeEditMessage(type, bufferOut);
if (type == PacketType::EntityAdd && !properties.getCertificateID().isEmpty()) {
emit addingEntityWithCertificate(properties.getCertificateID(), DependencyManager::get<AddressManager>()->getPlaceName());

View file

@ -1227,6 +1227,9 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
OctreePacketData ourDataPacket(false, buffer.size()); // create a packetData object to add out packet details too.
OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro
qDebug() << __FUNCTION__ << "OctreePacketData::getBytesAvailable():" << packetData->getBytesAvailable();
bool success = true; // assume the best
OctreeElement::AppendState appendState = OctreeElement::COMPLETED; // assume the best
@ -1525,9 +1528,15 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
const char* finalizedData = reinterpret_cast<const char*>(packetData->getFinalizedData());
int finalizedSize = packetData->getFinalizedSize();
qDebug() << __FUNCTION__ << "packetData->getFinalizedSize():" << packetData->getFinalizedSize();
qDebug() << __FUNCTION__ << "packetData->getUncompressedSize():" << packetData->getUncompressedSize();
qDebug() << __FUNCTION__ << "buffer.size():" << buffer.size();
if (finalizedSize <= buffer.size()) {
buffer.replace(0, finalizedSize, finalizedData, finalizedSize);
buffer.resize(finalizedSize);
qDebug() << __FUNCTION__ << "replaced with finalized data size:" << buffer.size();
} else {
qCDebug(entities) << "ERROR - encoded edit message doesn't fit in output buffer.";
success = false;

View file

@ -64,7 +64,8 @@ void PacketSender::queuePacketListForSending(const SharedNodePointer& destinatio
_totalPacketsQueued += packetList->getNumPackets();
_totalBytesQueued += packetList->getMessageSize();
qDebug() << __FUNCTION__ << "to:" << destinationNode->getUUID() << "type:" << packetList->getType() << "_totalPacketsQueued:" << _totalPacketsQueued << "_totalBytesQueued:" << _totalBytesQueued;
qDebug() << __FUNCTION__ << "to:" << destinationNode->getUUID() << "type:" << packetList->getType() << "size:" << packetList->getDataSize()
<< "_totalPacketsQueued:" << _totalPacketsQueued << "_totalBytesQueued:" << _totalBytesQueued;
lock();
_packets.push_back({ destinationNode, PacketOrPacketList { nullptr, std::move(packetList)} });
@ -288,18 +289,22 @@ bool PacketSender::nonThreadedProcess() {
// send the packet through the NodeList...
//PacketOrPacketList packetOrList = packetPair.second;
bool sendAsPacket = packetPair.second.first.get();
size_t packetSize = sendAsPacket ? packetPair.second.first->getDataSize() : packetPair.second.second->getMessageSize();
size_t packetCount = sendAsPacket ? 1 : packetPair.second.second->getNumPackets();
if (sendAsPacket) {
qDebug() << __FUNCTION__ << "sendUnreliablePacket() to:" << packetPair.first->getUUID() << "type:" << packetPair.second.first->getType();
DependencyManager::get<NodeList>()->sendUnreliablePacket(*packetPair.second.first, *packetPair.first);
} else {
qDebug() << __FUNCTION__ << "sendPacketList() to:" << packetPair.first->getUUID() << "type:" << packetPair.second.second->getType();
qDebug() << __FUNCTION__ << "sendPacketList() to:" << packetPair.first->getUUID() << "type:" << packetPair.second.second->getType()
<< "getMessageSize:" << packetPair.second.second->getMessageSize()
<< "getDataSize:" << packetPair.second.second->getDataSize();
DependencyManager::get<NodeList>()->sendPacketList(*packetPair.second.second, *packetPair.first);
}
size_t packetSize = sendAsPacket ? packetPair.second.first->getDataSize() : packetPair.second.second->getMessageSize();
size_t packetCount = sendAsPacket ? 1 : packetPair.second.second->getNumPackets();
packetsSentThisCall += packetCount;
_packetsOverCheckInterval += packetCount;
@ -311,7 +316,9 @@ bool PacketSender::nonThreadedProcess() {
qDebug() << __FUNCTION__ << "packetsSentThisCall:" << packetsSentThisCall
<< "_packetsOverCheckInterval:" << _packetsOverCheckInterval
<< "_totalPacketsSent:" << _totalPacketsSent;
<< "_totalPacketsSent:" << _totalPacketsSent
<< "packetSize:" << packetSize
<< "_totalBytesSent:" << _totalBytesSent;
_lastSendTime = now;
}

View file

@ -26,8 +26,10 @@ ReceivedMessage::ReceivedMessage(const NLPacketList& packetList)
_sourceID(packetList.getSourceID()),
_packetType(packetList.getType()),
_packetVersion(packetList.getVersion()),
_senderSockAddr(packetList.getSenderSockAddr())
_senderSockAddr(packetList.getSenderSockAddr()),
_fromPacketList(true)
{
qDebug() << __FUNCTION__ << "(const NLPacketList& packetList) _fromPacketList:" << _fromPacketList;
}
ReceivedMessage::ReceivedMessage(NLPacket& packet)
@ -38,8 +40,12 @@ ReceivedMessage::ReceivedMessage(NLPacket& packet)
_packetType(packet.getType()),
_packetVersion(packet.getVersion()),
_senderSockAddr(packet.getSenderSockAddr()),
_isComplete(packet.getPacketPosition() == NLPacket::ONLY)
_isComplete(packet.getPacketPosition() == NLPacket::ONLY),
_fromPacket(true)
{
if (packet.getType() == PacketType::EntityAdd) {
qDebug() << __FUNCTION__ << "(NLPacket& packet) _fromPacketList:" << _fromPacketList << "packet.getType():" << packet.getType();
}
}
ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
@ -51,9 +57,10 @@ ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, Pa
_packetType(packetType),
_packetVersion(packetVersion),
_senderSockAddr(senderSockAddr),
_isComplete(true)
_isComplete(true),
_fromByteArray(true)
{
qDebug() << __FUNCTION__ << "(QByteArray byteArray)... _fromPacketList:" << _fromPacketList;
}
void ReceivedMessage::setFailed() {

View file

@ -79,6 +79,10 @@ public:
template<typename T> qint64 readHeadPrimitive(T* data);
bool isFromPacketList() const { return _fromPacketList; };
bool isFromPacket() const { return _fromPacket; };
bool isFromByteArray() const { return _fromByteArray; };
signals:
void progress(qint64 size);
void completed();
@ -100,6 +104,12 @@ private:
std::atomic<bool> _isComplete { true };
std::atomic<bool> _failed { false };
std::atomic<bool> _fromPacketList { false };
std::atomic<bool> _fromPacket { false };
std::atomic<bool> _fromByteArray { false };
};
Q_DECLARE_METATYPE(ReceivedMessage*)

View file

@ -26,7 +26,12 @@ void ReceivedPacketProcessor::terminating() {
void ReceivedPacketProcessor::queueReceivedPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType();
qDebug() << __FUNCTION__ << "from:" << sendingNode->getUUID() << "type:" << message->getType()
<< "getNumPackets:" << message->getNumPackets()
<< "getSize:" << message->getSize()
<< "isFromPacketList:" << message->isFromPacketList()
<< "isComplete:" << message->isComplete()
;
lock();

View file

@ -119,7 +119,7 @@ void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, std::uniqu
// a known nodeID.
void OctreeEditPacketSender::queuePacketListToNode(const QUuid& nodeUUID, std::unique_ptr<NLPacketList> packetList) {
qDebug() << __FUNCTION__ << "to:" << nodeUUID << "type:" << packetList->getType();
qDebug() << __FUNCTION__ << "to:" << nodeUUID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
bool wantDebug = false;
DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node) {
@ -381,7 +381,7 @@ void OctreeEditPacketSender::releaseQueuedPacket(const QUuid& nodeID, std::uniqu
void OctreeEditPacketSender::releaseQueuedPacketList(const QUuid& nodeID, std::unique_ptr<NLPacketList> packetList) {
qDebug() << __FUNCTION__ << "to:" << nodeID << "type:" << packetList->getType();
qDebug() << __FUNCTION__ << "to:" << nodeID << "type:" << packetList->getType() << "size:" << packetList->getDataSize();
_releaseQueuedPacketMutex.lock();
if (packetList->getMessageSize() > 0 && packetList->getType() != PacketType::Unknown) {

View file

@ -35,7 +35,14 @@ OctreePacketData::OctreePacketData(bool enableCompression, int targetSize) {
void OctreePacketData::changeSettings(bool enableCompression, unsigned int targetSize) {
_enableCompression = enableCompression;
_targetSize = std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize);
_targetSize = targetSize; // std::min(MAX_OCTREE_UNCOMRESSED_PACKET_SIZE, targetSize);
_uncompressedByteArray.resize(_targetSize);
_compressedByteArray.resize(_targetSize);
_uncompressed = (unsigned char*)_uncompressedByteArray.data();
_compressed = (unsigned char*)_compressedByteArray.data();
reset();
}
@ -689,6 +696,8 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char *dataBytes, QVecto
uint16_t length;
memcpy(&length, dataBytes, sizeof(uint16_t));
dataBytes += sizeof(length);
// FIXME - this size check is wrong if we allow larger packets
if (length * sizeof(glm::vec3) > MAX_OCTREE_UNCOMRESSED_PACKET_SIZE) {
result.resize(0);
return sizeof(uint16_t);
@ -702,6 +711,8 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char *dataBytes, QVecto
uint16_t length;
memcpy(&length, dataBytes, sizeof(uint16_t));
dataBytes += sizeof(length);
// FIXME - this size check is wrong if we allow larger packets
if (length * sizeof(glm::quat) > MAX_OCTREE_UNCOMRESSED_PACKET_SIZE) {
result.resize(0);
return sizeof(uint16_t);
@ -720,6 +731,8 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QVecto
uint16_t length;
memcpy(&length, dataBytes, sizeof(uint16_t));
dataBytes += sizeof(length);
// FIXME - this size check is wrong if we allow larger packets
if (length * sizeof(float) > MAX_OCTREE_UNCOMRESSED_PACKET_SIZE) {
result.resize(0);
return sizeof(uint16_t);
@ -733,6 +746,8 @@ int OctreePacketData::unpackDataFromBytes(const unsigned char* dataBytes, QVecto
uint16_t length;
memcpy(&length, dataBytes, sizeof(uint16_t));
dataBytes += sizeof(length);
// FIXME - this size check is wrong if we allow larger packets
if (length / 8 > MAX_OCTREE_UNCOMRESSED_PACKET_SIZE) {
result.resize(0);
return sizeof(uint16_t);

View file

@ -279,7 +279,10 @@ private:
unsigned int _targetSize;
bool _enableCompression;
unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
//unsigned char _uncompressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
QByteArray _uncompressedByteArray;
unsigned char* _uncompressed { nullptr };
int _bytesInUse;
int _bytesAvailable;
int _subTreeAt;
@ -288,7 +291,9 @@ private:
bool compressContent();
unsigned char _compressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
//unsigned char _compressed[MAX_OCTREE_UNCOMRESSED_PACKET_SIZE];
QByteArray _compressedByteArray;
unsigned char* _compressed { nullptr };
int _compressedBytes;
int _bytesInUseLastCheck;
bool _dirty;