Don't try to set socket options on invalid socket.

This commit is contained in:
Bartosz Taudul 2019-04-01 20:08:27 +02:00
parent 8d0d6b576a
commit 687915299a

View File

@ -315,21 +315,17 @@ Socket* ListenSocket::Accept()
if( poll( &fd, 1, 10 ) > 0 ) if( poll( &fd, 1, 10 ) > 0 )
{ {
int sock = accept( m_sock, (sockaddr*)&remote, &sz); int sock = accept( m_sock, (sockaddr*)&remote, &sz);
if( sock == -1 ) return nullptr;
#if defined __APPLE__ #if defined __APPLE__
int val = 1; int val = 1;
setsockopt( sock, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof( val ) ); setsockopt( sock, SOL_SOCKET, SO_NOSIGPIPE, &val, sizeof( val ) );
#endif #endif
if( sock == -1 )
{
return nullptr;
}
else
{
auto ptr = (Socket*)tracy_malloc( sizeof( Socket ) ); auto ptr = (Socket*)tracy_malloc( sizeof( Socket ) );
new(ptr) Socket( sock ); new(ptr) Socket( sock );
return ptr; return ptr;
} }
}
else else
{ {
return nullptr; return nullptr;