| 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 | { |
no test coverage detected