From d3b005112ebc767875a38126972d8656d1acb5c1 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 7 Feb 2014 10:03:23 -0800 Subject: [PATCH] Changes from Philip's code review. --- libraries/metavoxels/src/Bitstream.cpp | 2 +- libraries/metavoxels/src/DatagramSequencer.cpp | 8 ++++++-- libraries/octree/src/OctreePacketData.h | 2 +- libraries/octree/src/OctreeSceneStats.h | 1 + libraries/shared/src/Logging.cpp | 2 +- libraries/shared/src/NetworkPacket.cpp | 2 +- libraries/shared/src/NetworkPacket.h | 2 +- libraries/shared/src/NodeList.h | 2 -- libraries/shared/src/OctalCode.h | 1 - libraries/shared/src/PacketSender.h | 1 + libraries/shared/src/SharedUtil.h | 4 ++++ 11 files changed, 17 insertions(+), 10 deletions(-) diff --git a/libraries/metavoxels/src/Bitstream.cpp b/libraries/metavoxels/src/Bitstream.cpp index c7b4758a26..262f2df7f5 100644 --- a/libraries/metavoxels/src/Bitstream.cpp +++ b/libraries/metavoxels/src/Bitstream.cpp @@ -15,6 +15,7 @@ #include #include +#include #include "AttributeRegistry.h" #include "Bitstream.h" @@ -96,7 +97,6 @@ Bitstream::Bitstream(QDataStream& underlying, QObject* parent) : _sharedObjectStreamer(*this) { } -const int BITS_IN_BYTE = 8; const int LAST_BIT_POSITION = BITS_IN_BYTE - 1; Bitstream& Bitstream::write(const void* data, int bits, int offset) { diff --git a/libraries/metavoxels/src/DatagramSequencer.cpp b/libraries/metavoxels/src/DatagramSequencer.cpp index e941d9e4d3..af271d97ba 100644 --- a/libraries/metavoxels/src/DatagramSequencer.cpp +++ b/libraries/metavoxels/src/DatagramSequencer.cpp @@ -10,10 +10,13 @@ #include +#include + #include "DatagramSequencer.h" #include "MetavoxelMessages.h" -const int MAX_DATAGRAM_SIZE = 1500; +// in sequencer parlance, a "packet" may consist of multiple datagrams. clarify when we refer to actual datagrams +const int MAX_DATAGRAM_SIZE = MAX_PACKET_SIZE; const int DEFAULT_MAX_PACKET_SIZE = 3000; @@ -515,7 +518,8 @@ void ReliableChannel::readData(QDataStream& in) { } } - // TODO: better way of pruning buffer? + // when the read head is sufficiently advanced into the buffer, prune it off. this along + // with other buffer usages should be replaced with a circular buffer const int PRUNE_SIZE = 8192; if (_buffer.pos() > PRUNE_SIZE) { _buffer.buffer() = _buffer.buffer().right(_buffer.size() - _buffer.pos()); diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index 76bb138516..a71a3f893c 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -224,4 +224,4 @@ private: static quint64 _totalBytesOfRawData; }; -#endif /* defined(__hifi__OctreePacketData__) */ \ No newline at end of file +#endif /* defined(__hifi__OctreePacketData__) */ diff --git a/libraries/octree/src/OctreeSceneStats.h b/libraries/octree/src/OctreeSceneStats.h index bf65e85ad4..e106f53589 100644 --- a/libraries/octree/src/OctreeSceneStats.h +++ b/libraries/octree/src/OctreeSceneStats.h @@ -12,6 +12,7 @@ #include #include +#include #include "JurisdictionMap.h" #define GREENISH 0x40ff40d0 diff --git a/libraries/shared/src/Logging.cpp b/libraries/shared/src/Logging.cpp index 6fb716e638..bc0d4af084 100644 --- a/libraries/shared/src/Logging.cpp +++ b/libraries/shared/src/Logging.cpp @@ -126,4 +126,4 @@ void Logging::verboseMessageHandler(QtMsgType type, const QMessageLogContext& co } fprintf(stdout, "%s %s\n", prefixString.toLocal8Bit().constData(), message.toLocal8Bit().constData()); -} \ No newline at end of file +} diff --git a/libraries/shared/src/NetworkPacket.cpp b/libraries/shared/src/NetworkPacket.cpp index aacd95dbbf..d0f0614088 100644 --- a/libraries/shared/src/NetworkPacket.cpp +++ b/libraries/shared/src/NetworkPacket.cpp @@ -48,4 +48,4 @@ NetworkPacket& NetworkPacket::operator=(NetworkPacket&& other) { copyContents(other.getAddress(), other.getByteArray()); return *this; } -#endif \ No newline at end of file +#endif diff --git a/libraries/shared/src/NetworkPacket.h b/libraries/shared/src/NetworkPacket.h index 480a793a49..c5a54b7939 100644 --- a/libraries/shared/src/NetworkPacket.h +++ b/libraries/shared/src/NetworkPacket.h @@ -20,7 +20,7 @@ #include "HifiSockAddr.h" -#include "NodeList.h" // for MAX_PACKET_SIZE +#include "SharedUtil.h" // for MAX_PACKET_SIZE /// Storage of not-yet processed inbound, or not yet sent outbound generic UDP network packet class NetworkPacket { diff --git a/libraries/shared/src/NodeList.h b/libraries/shared/src/NodeList.h index 6b8acd6e99..56e433a86f 100644 --- a/libraries/shared/src/NodeList.h +++ b/libraries/shared/src/NodeList.h @@ -30,8 +30,6 @@ #include "Node.h" -const int MAX_PACKET_SIZE = 1500; - const quint64 NODE_SILENCE_THRESHOLD_USECS = 2 * 1000 * 1000; const quint64 DOMAIN_SERVER_CHECK_IN_USECS = 1 * 1000000; const quint64 PING_INACTIVE_NODE_INTERVAL_USECS = 1 * 1000 * 1000; diff --git a/libraries/shared/src/OctalCode.h b/libraries/shared/src/OctalCode.h index 34d4264de4..36f3e74f63 100644 --- a/libraries/shared/src/OctalCode.h +++ b/libraries/shared/src/OctalCode.h @@ -12,7 +12,6 @@ #include #include -const int BITS_IN_BYTE = 8; const int BITS_IN_OCTAL = 3; const int NUMBER_OF_COLORS = 3; // RGB! const int SIZE_OF_COLOR_DATA = NUMBER_OF_COLORS * sizeof(unsigned char); // size in bytes diff --git a/libraries/shared/src/PacketSender.h b/libraries/shared/src/PacketSender.h index 4a1e62bd0c..83a146a096 100644 --- a/libraries/shared/src/PacketSender.h +++ b/libraries/shared/src/PacketSender.h @@ -13,6 +13,7 @@ #include "GenericThread.h" #include "NetworkPacket.h" +#include "NodeList.h" #include "SharedUtil.h" /// Generalized threaded processor for queueing and sending of outbound packets. diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index c982ab3596..603a09a0c3 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -61,6 +61,10 @@ static const quint64 USECS_PER_MSEC = 1000; static const quint64 MSECS_PER_SECOND = 1000; static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND; +const int BITS_IN_BYTE = 8; + +const int MAX_PACKET_SIZE = 1500; + quint64 usecTimestamp(const timeval *time); quint64 usecTimestampNow(); void usecTimestampNowForceClockSkew(int clockSkew);