Skip to content

Commit 20adcbe

Browse files
author
Steven Noonan
committed
test_connection: fix thread data race
As observed here: https://travis-ci.org/ValveSoftware/GameNetworkingSockets/jobs/639936441 We were setting the debug output function while the internal SteamNetworkingSockets thread was reading the value. No reason to not just set it up *before* using SteamNetworkingSockets. Signed-off-by: Steven Noonan <[email protected]>
1 parent 93a6cb7 commit 20adcbe

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/test_connection.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ static void Printf( const char *fmt, ... )
6565

6666
static void InitSteamDatagramConnectionSockets()
6767
{
68+
g_fpLog = fopen( "log.txt", "wt" );
69+
g_logTimeZero = SteamNetworkingUtils()->GetLocalTimestamp();
70+
71+
SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Debug, DebugOutput );
72+
//SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Verbose, DebugOutput );
73+
//SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Msg, DebugOutput );
74+
6875
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
6976
SteamDatagramErrMsg errMsg;
7077
if ( !GameNetworkingSockets_Init( nullptr, errMsg ) )
@@ -85,13 +92,6 @@ static void InitSteamDatagramConnectionSockets()
8592
exit(1);
8693
}
8794
#endif
88-
89-
g_fpLog = fopen( "log.txt", "wt" );
90-
g_logTimeZero = SteamNetworkingUtils()->GetLocalTimestamp();
91-
92-
SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Debug, DebugOutput );
93-
//SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Verbose, DebugOutput );
94-
//SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Msg, DebugOutput );
9595
}
9696

9797
static void ShutdownSteamDatagramConnectionSockets()

0 commit comments

Comments
 (0)