mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Proper handling of disconnect request.
This commit is contained in:
parent
344d36086f
commit
a4e7a341c0
@ -2064,6 +2064,9 @@ bool Profiler::HandleServerQuery()
|
|||||||
case ServerQueryFrameName:
|
case ServerQueryFrameName:
|
||||||
SendString( ptr, (const char*)ptr, QueueType::FrameName );
|
SendString( ptr, (const char*)ptr, QueueType::FrameName );
|
||||||
break;
|
break;
|
||||||
|
case ServerQueryDisconnect:
|
||||||
|
HandleDisconnect();
|
||||||
|
return false;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
@ -2072,6 +2075,35 @@ bool Profiler::HandleServerQuery()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profiler::HandleDisconnect()
|
||||||
|
{
|
||||||
|
QueueItem terminate;
|
||||||
|
MemWrite( &terminate.hdr.type, QueueType::Terminate );
|
||||||
|
if( !SendData( (const char*)&terminate, 1 ) ) return;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
if( m_sock->HasData() )
|
||||||
|
{
|
||||||
|
while( m_sock->HasData() )
|
||||||
|
{
|
||||||
|
if( !HandleServerQuery() ) return;
|
||||||
|
}
|
||||||
|
if( m_bufferOffset != m_bufferStart )
|
||||||
|
{
|
||||||
|
if( !CommitData() ) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( m_bufferOffset != m_bufferStart )
|
||||||
|
{
|
||||||
|
if( !CommitData() ) return;
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Profiler::CalibrateTimer()
|
void Profiler::CalibrateTimer()
|
||||||
{
|
{
|
||||||
#ifdef TRACY_HW_TIMER
|
#ifdef TRACY_HW_TIMER
|
||||||
|
@ -487,6 +487,7 @@ private:
|
|||||||
void SendCallstackFrame( uint64_t ptr );
|
void SendCallstackFrame( uint64_t ptr );
|
||||||
|
|
||||||
bool HandleServerQuery();
|
bool HandleServerQuery();
|
||||||
|
void HandleDisconnect();
|
||||||
|
|
||||||
void CalibrateTimer();
|
void CalibrateTimer();
|
||||||
void CalibrateDelay();
|
void CalibrateDelay();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
namespace tracy
|
namespace tracy
|
||||||
{
|
{
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 12 };
|
enum : uint32_t { ProtocolVersion = 13 };
|
||||||
enum : uint32_t { BroadcastVersion = 0 };
|
enum : uint32_t { BroadcastVersion = 0 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
@ -45,6 +45,7 @@ enum ServerQuery : uint8_t
|
|||||||
ServerQueryPlotName,
|
ServerQueryPlotName,
|
||||||
ServerQueryCallstackFrame,
|
ServerQueryCallstackFrame,
|
||||||
ServerQueryFrameName,
|
ServerQueryFrameName,
|
||||||
|
ServerQueryDisconnect
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ServerQueryPacket
|
struct ServerQueryPacket
|
||||||
|
@ -817,11 +817,12 @@ bool View::DrawConnection()
|
|||||||
const char* stopStr = "Stop";
|
const char* stopStr = "Stop";
|
||||||
#endif
|
#endif
|
||||||
std::shared_lock<std::shared_mutex> lock( m_worker.GetDataLock() );
|
std::shared_lock<std::shared_mutex> lock( m_worker.GetDataLock() );
|
||||||
if( m_worker.IsConnected() )
|
if( !m_disconnectIssued && m_worker.IsConnected() )
|
||||||
{
|
{
|
||||||
if( ImGui::Button( stopStr ) )
|
if( ImGui::Button( stopStr ) )
|
||||||
{
|
{
|
||||||
m_worker.Disconnect();
|
m_worker.Disconnect();
|
||||||
|
m_disconnectIssued = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -271,6 +271,7 @@ private:
|
|||||||
ImGuiTextFilter m_messageFilter;
|
ImGuiTextFilter m_messageFilter;
|
||||||
bool m_messageFilterWasActive = false;
|
bool m_messageFilterWasActive = false;
|
||||||
int m_visibleMessages = 0;
|
int m_visibleMessages = 0;
|
||||||
|
bool m_disconnectIssued = false;
|
||||||
|
|
||||||
Region m_highlight;
|
Region m_highlight;
|
||||||
Region m_highlightZoom;
|
Region m_highlightZoom;
|
||||||
|
@ -1948,7 +1948,7 @@ void Worker::Exec()
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if( !m_crashed )
|
if( !m_crashed && !m_disconnect )
|
||||||
{
|
{
|
||||||
bool done = true;
|
bool done = true;
|
||||||
for( auto& v : m_data.threads )
|
for( auto& v : m_data.threads )
|
||||||
@ -4193,6 +4193,12 @@ void Worker::ReadTimelinePre044( FileRead& f, Vector<GpuEvent*>& vec, uint64_t s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::Disconnect()
|
||||||
|
{
|
||||||
|
Query( ServerQueryDisconnect, 0 );
|
||||||
|
m_disconnect = true;
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::Write( FileWrite& f )
|
void Worker::Write( FileWrite& f )
|
||||||
{
|
{
|
||||||
f.Write( FileHeader, sizeof( FileHeader ) );
|
f.Write( FileHeader, sizeof( FileHeader ) );
|
||||||
|
@ -336,7 +336,7 @@ public:
|
|||||||
bool IsDataStatic() const { return !m_thread.joinable(); }
|
bool IsDataStatic() const { return !m_thread.joinable(); }
|
||||||
bool IsBackgroundDone() const { return m_backgroundDone.load( std::memory_order_relaxed ); }
|
bool IsBackgroundDone() const { return m_backgroundDone.load( std::memory_order_relaxed ); }
|
||||||
void Shutdown() { m_shutdown.store( true, std::memory_order_relaxed ); }
|
void Shutdown() { m_shutdown.store( true, std::memory_order_relaxed ); }
|
||||||
void Disconnect() { Shutdown(); } // TODO: Needs proper implementation.
|
void Disconnect();
|
||||||
|
|
||||||
void Write( FileWrite& f );
|
void Write( FileWrite& f );
|
||||||
int GetTraceVersion() const { return m_traceVersion; }
|
int GetTraceVersion() const { return m_traceVersion; }
|
||||||
@ -498,6 +498,7 @@ private:
|
|||||||
std::string m_hostInfo;
|
std::string m_hostInfo;
|
||||||
bool m_terminate = false;
|
bool m_terminate = false;
|
||||||
bool m_crashed = false;
|
bool m_crashed = false;
|
||||||
|
bool m_disconnect = false;
|
||||||
LZ4_streamDecode_t* m_stream;
|
LZ4_streamDecode_t* m_stream;
|
||||||
char* m_buffer;
|
char* m_buffer;
|
||||||
int m_bufferOffset;
|
int m_bufferOffset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user