mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Use proper function to read data from socket.
This commit is contained in:
parent
3dd744019a
commit
f0d76af15c
@ -35,6 +35,11 @@ View::~View()
|
|||||||
m_thread.join();
|
m_thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool View::ShouldExit()
|
||||||
|
{
|
||||||
|
return s_instance->m_shutdown.load( std::memory_order_relaxed );
|
||||||
|
}
|
||||||
|
|
||||||
void View::Worker()
|
void View::Worker()
|
||||||
{
|
{
|
||||||
Socket sock;
|
Socket sock;
|
||||||
@ -48,26 +53,10 @@ void View::Worker()
|
|||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
||||||
if( !sock.Connect( m_addr.c_str(), "8086" ) ) continue;
|
if( !sock.Connect( m_addr.c_str(), "8086" ) ) continue;
|
||||||
|
|
||||||
auto left = sizeof( m_timeBegin );
|
|
||||||
auto ptr = (char*)&m_timeBegin;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
|
||||||
auto sz = sock.Recv( ptr, left, &tv );
|
|
||||||
if( sz == 0 ) goto close;
|
|
||||||
if( sz > 0 )
|
|
||||||
{
|
|
||||||
left -= sz;
|
|
||||||
ptr += sz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while( left > 0 );
|
|
||||||
|
|
||||||
uint8_t lz4;
|
uint8_t lz4;
|
||||||
while( sock.Recv( &lz4, 1, nullptr ) == -1 )
|
|
||||||
{
|
if( !sock.Read( &m_timeBegin, sizeof( m_timeBegin ), &tv, ShouldExit ) ) goto close;
|
||||||
if( m_shutdown.load( std::memory_order_relaxed ) ) return;
|
if( !sock.Read( &lz4, sizeof( lz4 ), &tv, ShouldExit ) ) goto close;
|
||||||
}
|
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,8 @@ public:
|
|||||||
View( const char* addr );
|
View( const char* addr );
|
||||||
~View();
|
~View();
|
||||||
|
|
||||||
|
static bool ShouldExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Worker();
|
void Worker();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user