diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp index d96694e..0bd34f0 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp @@ -1164,7 +1164,12 @@ IThinker::~IThinker() void IThinker::SetNextThinkTime( SteamNetworkingMicroseconds usecTargetThinkTime ) { - Assert( usecTargetThinkTime > 0 ); + // Protect against us blowing up because of an invalid think time + if ( usecTargetThinkTime <= 0 ) + { + AssertMsg1( false, "Attempt to set target think time to %lld", (long long)usecTargetThinkTime ); + usecTargetThinkTime = Plat_USTime() + 5000; + } // Clearing it? if ( usecTargetThinkTime == k_nThinkTime_Never ) @@ -1221,6 +1226,7 @@ void ProcessThinkers() { // Until the queue is empty + int nIterations = 0; while ( s_queueThinkers.Count() > 0 ) { @@ -1242,6 +1248,13 @@ void ProcessThinkers() break; } + ++nIterations; + if ( nIterations > 10000 ) + { + AssertMsg1( false, "Processed thinkers %d times -- probably one thinker keeps requesting an immediate wakeup call.", nIterations ); + break; + } + // Go ahead and clear his think time now and remove him // from the heap. He needs to schedule a new think time // if heeds service again. For thinkers that need frequent @@ -1317,7 +1330,7 @@ static bool SteamNetworkingSockets_InternalPoll( int msWait, bool bManualPoll ) } } - // Con't ever sleep for too long, just in case. This timeout + // Don't ever sleep for too long, just in case. This timeout // is long enough so that if we have a bug where we really need to // be explicitly waking the thread for good perf, we will notice // the delay. But not so long that a bug in some rare