Init winsock at application init, not on first socket use.

This commit is contained in:
Bartosz Taudul 2017-09-14 02:13:45 +02:00
parent a159b70d40
commit ef7dca9073

View File

@ -19,12 +19,10 @@ namespace tracy
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
static bool initDone = false; struct __wsinit
static void InitWinSock()
{ {
if( !initDone ) __wsinit()
{ {
initDone = true;
WSADATA wsaData; WSADATA wsaData;
if( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) != 0 ) if( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) != 0 )
{ {
@ -32,23 +30,17 @@ static void InitWinSock()
exit( 1 ); exit( 1 );
} }
} }
} } ___wsinit;
#endif #endif
Socket::Socket() Socket::Socket()
: m_sock( -1 ) : m_sock( -1 )
{ {
#ifdef _MSC_VER
InitWinSock();
#endif
} }
Socket::Socket( int sock ) Socket::Socket( int sock )
: m_sock( sock ) : m_sock( sock )
{ {
#ifdef _MSC_VER
assert( initDone );
#endif
} }
Socket::~Socket() Socket::~Socket()
@ -179,9 +171,6 @@ bool Socket::HasData()
ListenSocket::ListenSocket() ListenSocket::ListenSocket()
: m_sock( -1 ) : m_sock( -1 )
{ {
#ifdef _MSC_VER
InitWinSock();
#endif
} }
ListenSocket::~ListenSocket() ListenSocket::~ListenSocket()