Skip to content

Commit

Permalink
fix dns resolver discard_cache (#497)
Browse files Browse the repository at this point in the history
Signed-off-by: liulanzheng <lanzheng.liulz@alibaba-inc.com>
  • Loading branch information
liulanzheng committed May 30, 2024
1 parent 40507a6 commit 2244d0d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ class DefaultResolver : public Resolver {

void discard_cache(const char *host, IPAddr ip) override {
auto ipaddr = dnscache_.borrow(host);
if (ip.undefined() || ipaddr->empty()) ipaddr.recycle(true);
else {
if (ip.undefined() || ipaddr->empty()) {
ipaddr->delete_all();
ipaddr.recycle(true);
} else {
for (auto itr = ipaddr->rbegin(); itr != ipaddr->rend(); itr++) {
if ((*itr)->addr == ip) {
ipaddr->erase(*itr);
Expand Down

0 comments on commit 2244d0d

Please sign in to comment.