Protect against time calcuation underflows in ConnectionManager::gc

- misc: remove mostly useless log statement in Helper::getSdp
This commit is contained in:
Scott Godin
2025-10-24 11:53:07 -04:00
parent cf01405fa3
commit f677712a1a
2 changed files with 4 additions and 3 deletions

View File

@@ -244,7 +244,8 @@ unsigned int
ConnectionManager::gc(uint64_t relThreshold, unsigned int maxToRemove)
{
uint64_t curTimeMs = Timer::getTimeMs();
uint64_t threshold = curTimeMs - relThreshold;
uint64_t threshold = curTimeMs > relThreshold ? curTimeMs - relThreshold : 0; // Ensure we don't underflow
DebugLog(<< "recycling connections not used in last " << relThreshold/1000.0 << " seconds");
// Look through non-flow-timer connections and close those using the passed in relThreshold

View File

@@ -2275,12 +2275,12 @@ unique_ptr<SdpContents> Helper::getSdp(Contents* tree)
if (sdp)
{
DebugLog(<< "Got sdp" << endl);
//DebugLog(<< "Got sdp");
return unique_ptr<SdpContents>(static_cast<SdpContents*>(sdp->clone()));
}
}
//DebugLog(<< "No sdp" << endl);
//DebugLog(<< "No sdp");
return nullptr;
}