MCPcopy Create free account
hub / github.com/aria2/aria2 / findSocketPoolEntry

Method findSocketPoolEntry

src/DownloadEngine.cc:438–454  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436}
437
438std::multimap<std::string, DownloadEngine::SocketPoolEntry>::iterator
439DownloadEngine::findSocketPoolEntry(const std::string& key)
440{
441 std::pair<std::multimap<std::string, SocketPoolEntry>::iterator,
442 std::multimap<std::string, SocketPoolEntry>::iterator>
443 range = socketPool_.equal_range(key);
444 for (auto i = range.first, eoi = range.second; i != eoi; ++i) {
445 const SocketPoolEntry& e = (*i).second;
446 // We assume that if socket is readable it means peer shutdowns
447 // connection and the socket will receive EOF. So skip it.
448 if (!e.isTimeout() && !e.getSocket()->isReadable(0)) {
449 A2_LOG_INFO(fmt("Found socket for %s", key.c_str()));
450 return i;
451 }
452 }
453 return socketPool_.end();
454}
455
456std::shared_ptr<SocketCore>
457DownloadEngine::popPooledSocket(const std::string& ipaddr, uint16_t port,

Callers

nothing calls this directly

Calls 5

fmtFunction · 0.85
isReadableMethod · 0.80
isTimeoutMethod · 0.45
getSocketMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected