@@ -156,12 +156,21 @@ struct ThreadLockDebugInfo
156156
157157static void (*s_fLockAcquiredCallback)( const char *tags, SteamNetworkingMicroseconds usecWaited );
158158static void (*s_fLockHeldCallback)( const char *tags, SteamNetworkingMicroseconds usecWaited );
159+
160+ // Threshold for warning about waiting on any lock.
159161#ifdef __SANITIZE_THREAD__
160162static SteamNetworkingMicroseconds s_usecLockWaitWarningThreshold = 300 *1000 ;
161163#else
162164static SteamNetworkingMicroseconds s_usecLockWaitWarningThreshold = 2 *1000 ;
163165#endif
164166
167+ // Threshold for the service-thread-specific *assert*
168+ #ifdef __SANITIZE_THREAD__
169+ static SteamNetworkingMicroseconds s_usecServiceThreadLockWaitWarning = 300 *1000 ;
170+ #else
171+ static SteamNetworkingMicroseconds s_usecServiceThreadLockWaitWarning = 50 *1000 ;
172+ #endif
173+
165174// / Get the per-thread debug info
166175static ThreadLockDebugInfo &GetThreadDebugInfo ()
167176{
@@ -2877,15 +2886,7 @@ static bool PollRawUDPSockets( int nMaxTimeoutMS, bool bManualPoll )
28772886 #ifdef DBGFLAG_ASSERT
28782887 {
28792888 SteamNetworkingMicroseconds usecElapsedWaitingForLock = SteamNetworkingSockets_GetLocalTimestamp () - usecStartedLocking;
2880- // Hm, if another thread indicated that they expected to hold the lock for a while,
2881- // perhaps we should ignore this assert?
2882- // TSan adds 10-20x overhead so the threshold is scaled up accordingly.
2883- #ifdef __SANITIZE_THREAD__
2884- constexpr SteamNetworkingMicroseconds k_usecServiceThreadLockWaitWarning = 300 *1000 ;
2885- #else
2886- constexpr SteamNetworkingMicroseconds k_usecServiceThreadLockWaitWarning = 50 *1000 ;
2887- #endif
2888- AssertMsg1 ( usecElapsedWaitingForLock < k_usecServiceThreadLockWaitWarning || Plat_IsInDebugSession (),
2889+ AssertMsg1 ( usecElapsedWaitingForLock < s_usecServiceThreadLockWaitWarning || Plat_IsInDebugSession (),
28892890 " SteamnetworkingSockets service thread waited %dms for lock! This directly adds to network latency! It could be a bug, but it's usually caused by general performance problem such as thread starvation or a debug output handler taking too long." , int ( usecElapsedWaitingForLock/1000 ) );
28902891 }
28912892 #endif
@@ -4643,9 +4644,8 @@ STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetLockWaitWarningT
46434644{
46444645 #if STEAMNETWORKINGSOCKETS_LOCK_DEBUG_LEVEL > 0
46454646 s_usecLockWaitWarningThreshold = usecTheshold;
4646- #else
4647- // Should we assert here?
46484647 #endif
4648+ s_usecServiceThreadLockWaitWarning = usecTheshold;
46494649}
46504650
46514651STEAMNETWORKINGSOCKETS_INTERFACE void SteamNetworkingSockets_SetLockAcquiredCallback ( void (*callback)( const char *tags, SteamNetworkingMicroseconds usecWaited ) )
0 commit comments