From f0d93dcde4affff88f584b397cf5b3da505dcfba Mon Sep 17 00:00:00 2001 From: Joe Landers Date: Tue, 7 Jul 2020 22:02:24 +0200 Subject: [PATCH 1/2] hostdb: don't use next_sync_time - now() as TTL (it can be negative) --- iocore/hostdb/HostDB.cc | 5 ++--- iocore/hostdb/P_HostDBProcessor.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index f06a39c3c71..d03d48dd14a 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -1654,9 +1654,9 @@ HostDBContinuation::do_dns() HostsFileMap::iterator find_result = current_host_file_map->hosts_file_map.find(hname); if (find_result != current_host_file_map->hosts_file_map.end()) { if (action.continuation) { - // Set the TTL based on how much time remains until the next sync + // Set the TTL based on how often we stat() the host file HostDBInfo *r = lookup_done(IpAddr(find_result->second), hash.host_name, false, - current_host_file_map->next_sync_time - ink_time(), nullptr); + hostdb_hostfile_check_interval, nullptr); reply_to_cont(action.continuation, r); } hostdb_cont_free(this); @@ -2241,7 +2241,6 @@ ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval_pars int64_t size = info.st_size + 1; parsed_hosts_file_ptr = new RefCountedHostsFileMap; - parsed_hosts_file_ptr->next_sync_time = ink_time() + hostdb_hostfile_check_interval_parse; parsed_hosts_file_ptr->HostFileText = static_cast(ats_malloc(size)); if (parsed_hosts_file_ptr->HostFileText) { char *base = parsed_hosts_file_ptr->HostFileText; diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h index ac14387f979..b903049f4f7 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -182,7 +182,6 @@ typedef std::map HostsF struct RefCountedHostsFileMap : public RefCountObj { HostsFileMap hosts_file_map; ats_scoped_str HostFileText; - ink_time_t next_sync_time; // time of the next sync }; // From 899b32913cccd4f26670d1329b904ba8dde11c4e Mon Sep 17 00:00:00 2001 From: Joe Landers Date: Wed, 8 Jul 2020 10:56:54 +0200 Subject: [PATCH 2/2] make clang-format happy --- iocore/hostdb/HostDB.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index d03d48dd14a..2fa10fc9826 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -1655,8 +1655,7 @@ HostDBContinuation::do_dns() if (find_result != current_host_file_map->hosts_file_map.end()) { if (action.continuation) { // Set the TTL based on how often we stat() the host file - HostDBInfo *r = lookup_done(IpAddr(find_result->second), hash.host_name, false, - hostdb_hostfile_check_interval, nullptr); + HostDBInfo *r = lookup_done(IpAddr(find_result->second), hash.host_name, false, hostdb_hostfile_check_interval, nullptr); reply_to_cont(action.continuation, r); } hostdb_cont_free(this); @@ -2240,8 +2239,8 @@ ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval_pars // +1 in case no terminating newline int64_t size = info.st_size + 1; - parsed_hosts_file_ptr = new RefCountedHostsFileMap; - parsed_hosts_file_ptr->HostFileText = static_cast(ats_malloc(size)); + parsed_hosts_file_ptr = new RefCountedHostsFileMap; + parsed_hosts_file_ptr->HostFileText = static_cast(ats_malloc(size)); if (parsed_hosts_file_ptr->HostFileText) { char *base = parsed_hosts_file_ptr->HostFileText; char *limit;