MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / CleanUp

Method CleanUp

libi2pd/Datagram.cpp:483–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 }
482
483 void DatagramDestination::CleanUp ()
484 {
485 if (m_Sessions.empty ()) return;
486 auto now = i2p::util::GetMillisecondsSinceEpoch();
487 LogPrint(eLogDebug, "DatagramDestination: clean up sessions");
488 std::unique_lock<std::mutex> lock(m_SessionsMutex);
489 // for each session ...
490 for (auto it = m_Sessions.begin (); it != m_Sessions.end (); )
491 {
492 // check if expired
493 if (now - it->second->LastActivity() >= DATAGRAM_SESSION_MAX_IDLE)
494 {
495 LogPrint(eLogInfo, "DatagramDestination: expiring idle session with ", it->first.ToBase32());
496 it->second->Stop ();
497 it = m_Sessions.erase (it); // we are expired
498 }
499 else
500 it++;
501 }
502 }
503
504 std::shared_ptr<DatagramSession> DatagramDestination::ObtainSession(const i2p::data::IdentHash & identity)
505 {

Callers 2

HandleDatagram2Method · 0.45
HandleDatagram3Method · 0.45

Calls 4

LogPrintFunction · 0.85
LastActivityMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected