protected void TimeoutCheck() {
_rrm.TimeoutChecker(null, null);
DateTime now = DateTime.UtcNow;
long next = _next_check;
if(next < now.Ticks) {
// If someone else is checking it, let's just end it here
long current = Interlocked.Exchange(ref _next_check, now.AddMinutes(5).Ticks);
if(next != current) {
return;
}
}
// Get the list of old edges
DateTime remove_timeout = now.AddMinutes(-5);
List<Edge> to_close = new List<Edge>();
lock(_sync) {
foreach(Edge e in _unannounced.Keys) {
if(e.CreatedDateTime < remove_timeout) {
to_close.Add(e);
}
}
}
// Close the Edges
foreach(Edge e in to_close) {
PathEdge pe = null;
if(!_unannounced.TryGetValue(e, out pe)) {
continue;
}
try {
pe.Close();
} catch(Exception ex) {
Console.WriteLine(ex);
}
}
// Remove them from the _unannounced dictionary
lock(_sync) {
foreach(Edge e in to_close) {
_unannounced.Remove(e);
}
}
}