| 689 | return cache.end(); |
| 690 | } |
| 691 | TIntrusivePtr<IConnection> GetConnection(const TUdpAddress& addr, const TConnectionSettings& connectionSettings) const { |
| 692 | // actually may occur after bad dns resolving |
| 693 | // Y_ASSERT(addr != TUdpAddress()); |
| 694 | |
| 695 | TConnectionsCache::iterator c = Find(ConnectionsCache, addr, connectionSettings); |
| 696 | if (c != ConnectionsCache.end()) { |
| 697 | Y_ASSERT(Find(OldConnectionsCache, addr, connectionSettings) == OldConnectionsCache.end()); |
| 698 | return c->second; |
| 699 | } |
| 700 | |
| 701 | TIntrusivePtr<IConnection> connection; |
| 702 | |
| 703 | c = Find(OldConnectionsCache, addr, connectionSettings); |
| 704 | if (c != OldConnectionsCache.end()) { |
| 705 | connection = c->second; |
| 706 | OldConnectionsCache.erase(c); |
| 707 | } else { |
| 708 | connection = Host->Connect(addr, connectionSettings); |
| 709 | } |
| 710 | ConnectionsCache.insert(std::make_pair(addr, connection)); |
| 711 | |
| 712 | return connection; |
| 713 | } |
| 714 | void CacheConnection(const TIntrusivePtr<IConnection>& connection) const { |
| 715 | const TUdpAddress& addr = connection->GetAddress(); |
| 716 | const TConnectionSettings& connectionSettings = connection->GetSettings(); |