diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 419e9be9..68e61618 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -78,16 +78,19 @@ void View::Worker() while( ptr < end ) { auto ev = (QueueItem*)ptr; - Process( *ev ); - ptr += QueueDataSize[ev->hdr.idx]; + DispatchProcess( *ev, ptr ); } } else { QueueItem ev; if( !m_sock.Read( &ev.hdr, sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close; - if( !m_sock.Read( ((char*)&ev) + sizeof( QueueHeader ), QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader ), &tv, ShouldExit ) ) goto close; - Process( ev ); + const auto payload = QueueDataSize[ev.hdr.idx] - sizeof( QueueHeader ); + if( payload > 0 ) + { + if( !m_sock.Read( ((char*)&ev) + sizeof( QueueHeader ), payload, &tv, ShouldExit ) ) goto close; + } + DispatchProcess( ev ); } } @@ -96,6 +99,43 @@ close: } } +void View::DispatchProcess( const QueueItem& ev ) +{ + if( ev.hdr.type == QueueType::StringData ) + { + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = 10000; + + char buf[TargetFrameSize]; + uint16_t sz; + m_sock.Read( &sz, sizeof( sz ), &tv, ShouldExit ); + m_sock.Read( buf, sz, &tv, ShouldExit ); + AddString( ev.hdr.id, std::string( buf, buf+sz ) ); + } + else + { + Process( ev ); + } +} + +void View::DispatchProcess( const QueueItem& ev, const char*& ptr ) +{ + ptr += QueueDataSize[ev.hdr.idx]; + if( ev.hdr.type == QueueType::StringData ) + { + uint16_t sz; + memcpy( &sz, ptr, sizeof( sz ) ); + ptr += sizeof( sz ); + AddString( ev.hdr.id, std::string( ptr, ptr+sz ) ); + ptr += sz; + } + else + { + Process( ev ); + } +} + void View::Process( const QueueItem& ev ) { switch( ev.hdr.type ) diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 7e8f81a7..79998c20 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -29,8 +29,11 @@ public: private: void Worker(); - void Process( const QueueItem& ev ); + void DispatchProcess( const QueueItem& ev ); + void DispatchProcess( const QueueItem& ev, const char*& ptr ); + + void Process( const QueueItem& ev ); void ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev ); void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );