| 324 | } |
| 325 | |
| 326 | void discard_cache(std::string_view host, IPAddr ip) override { |
| 327 | auto ipaddr = dnscache_.borrow(host); |
| 328 | if (ip.undefined() || ipaddr->empty()) { |
| 329 | ipaddr.recycle(true); |
| 330 | } else { |
| 331 | IPAddrNode* node = nullptr; |
| 332 | DEFER(delete node); |
| 333 | SCOPED_LOCK(*ipaddr); |
| 334 | for (auto itr = ipaddr->rbegin(); itr != ipaddr->rend(); itr++) { |
| 335 | if ((*itr)->addr == ip) { |
| 336 | ipaddr->erase(node = *itr); |
| 337 | break; |
| 338 | } |
| 339 | } |
| 340 | ipaddr.recycle(ipaddr->empty()); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | private: |
| 345 | ObjectCache<std::string, IPAddrList*> dnscache_; |