Socket::ReadUpTo() doesn't support timeouts.

This commit is contained in:
Bartosz Taudul 2023-04-16 12:19:48 +02:00
parent 72dfab80f8
commit 778d0cb3fb
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 3 additions and 3 deletions

View File

@ -80,7 +80,7 @@ void HttpRequest( const char* server, const char* resource, int port, std::funct
const auto len = sprintf( request, "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Tracy Profiler %i.%i.%i (%s)\r\nConnection: close\r\nCache-Control: no-cache, no-store, must-revalidate\r\n\r\n", resource, server, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, GetOsInfo() ); const auto len = sprintf( request, "GET %s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Tracy Profiler %i.%i.%i (%s)\r\nConnection: close\r\nCache-Control: no-cache, no-store, must-revalidate\r\n\r\n", resource, server, tracy::Version::Major, tracy::Version::Minor, tracy::Version::Patch, GetOsInfo() );
sock.Send( request, len ); sock.Send( request, len );
char response[4096]; char response[4096];
const auto sz = sock.ReadUpTo( response, 4096, 15 ); const auto sz = sock.ReadUpTo( response, 4096 );
if( sz < 13 ) return; if( sz < 13 ) return;
if( memcmp( response, "HTTP/1.1 200", 12 ) != 0 ) return; if( memcmp( response, "HTTP/1.1 200", 12 ) != 0 ) return;
auto hdr = response + 13; auto hdr = response + 13;

View File

@ -353,7 +353,7 @@ int Socket::Recv( void* _buf, int len, int timeout )
} }
} }
int Socket::ReadUpTo( void* _buf, int len, int timeout ) int Socket::ReadUpTo( void* _buf, int len )
{ {
const auto sock = m_sock.load( std::memory_order_relaxed ); const auto sock = m_sock.load( std::memory_order_relaxed );
auto buf = (char*)_buf; auto buf = (char*)_buf;

View File

@ -29,7 +29,7 @@ public:
int Send( const void* buf, int len ); int Send( const void* buf, int len );
int GetSendBufSize(); int GetSendBufSize();
int ReadUpTo( void* buf, int len, int timeout ); int ReadUpTo( void* buf, int len );
bool Read( void* buf, int len, int timeout ); bool Read( void* buf, int len, int timeout );
template<typename ShouldExit> template<typename ShouldExit>