Don't send unused data.

This commit is contained in:
Bartosz Taudul 2017-09-12 01:14:04 +02:00
parent 25d7cebd8a
commit 3df4cf8acd
2 changed files with 18 additions and 2 deletions

View File

@ -99,7 +99,15 @@ void Profiler::Worker()
const auto sz = m_queue.try_dequeue_bulk( token, item, BulkSize ); const auto sz = m_queue.try_dequeue_bulk( token, item, BulkSize );
if( sz > 0 ) if( sz > 0 )
{ {
if( sock->Send( item, sz * sizeof( QueueItem ) ) == -1 ) break; char buf[TargetFrameSize];
char* ptr = buf;
for( int i=0; i<sz; i++ )
{
const auto dsz = QueueDataSize[(uint8_t)item[i].hdr.type];
memcpy( ptr, item+i, dsz );
ptr += dsz;
}
if( sock->Send( buf, ptr - buf ) == -1 ) break;
} }
else else
{ {

View File

@ -9,7 +9,8 @@ namespace tracy
enum class QueueType : uint8_t enum class QueueType : uint8_t
{ {
ZoneBegin, ZoneBegin,
ZoneEnd ZoneEnd,
NUM_TYPES
}; };
#pragma pack( 1 ) #pragma pack( 1 )
@ -47,6 +48,13 @@ struct QueueItem
enum { QueueItemSize = sizeof( QueueItem ) }; enum { QueueItemSize = sizeof( QueueItem ) };
static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),
};
static_assert( sizeof( QueueDataSize ) / sizeof( size_t ) == (uint8_t)QueueType::NUM_TYPES, "QueueDataSize mismatch" );
}; };
#endif #endif