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

Method DeleteStream

libi2pd/Streaming.cpp:2278–2305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2276 }
2277
2278 void StreamingDestination::DeleteStream (std::shared_ptr<Stream> stream)
2279 {
2280 if (stream)
2281 {
2282 std::unique_lock<std::mutex> l(m_StreamsMutex);
2283 m_Streams.erase (stream->GetRecvStreamID ());
2284 if (stream->IsIncoming ())
2285 m_IncomingStreams.erase (stream->GetSendStreamID ());
2286 if (m_LastStream == stream) m_LastStream = nullptr;
2287 }
2288 auto ts = i2p::util::GetSecondsSinceEpoch ();
2289 if (m_Streams.empty () || ts > m_LastCleanupTime + STREAMING_DESTINATION_POOLS_CLEANUP_INTERVAL)
2290 {
2291 m_PacketsPool.CleanUp ();
2292 m_I2NPMsgsPool.CleanUp ();
2293 if (!m_NumIncomingConnectionsPerSecond.empty ())
2294 {
2295 for (auto it = m_NumIncomingConnectionsPerSecond.begin (); it != m_NumIncomingConnectionsPerSecond.end ();)
2296 {
2297 if (it->second.empty () || it->second.back () + 60 < ts) // newest is too old
2298 it = m_NumIncomingConnectionsPerSecond.erase (it);
2299 else
2300 it++;
2301 }
2302 }
2303 m_LastCleanupTime = ts;
2304 }
2305 }
2306
2307 bool StreamingDestination::DeleteStream (uint32_t recvStreamID)
2308 {

Callers 2

HandleCommandMethod · 0.45
TerminateMethod · 0.45

Calls 7

GetSecondsSinceEpochFunction · 0.85
GetRecvStreamIDMethod · 0.80
IsIncomingMethod · 0.80
GetSendStreamIDMethod · 0.45
CleanUpMethod · 0.45
CloseMethod · 0.45
TerminateMethod · 0.45

Tested by

no test coverage detected