You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by cm...@apache.org on 2024/03/05 15:33:25 UTC
(trafficserver) 01/08: fix hostdb.host_file.interval to be set at reconfig time (#11104)
This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 6ae8ccbd5aec410efe9cf260bf4c21733c5b6069
Author: Chris McFarlen <ch...@mcfarlen.us>
AuthorDate: Mon Mar 4 17:31:15 2024 -0600
fix hostdb.host_file.interval to be set at reconfig time (#11104)
Co-authored-by: Chris McFarlen <cm...@apple.com>
(cherry picked from commit 007caf8e72e73da885d3b3d9e7cc7125fbcf61d6)
---
src/iocore/hostdb/HostDB.cc | 26 +++++++++++++++-----------
src/iocore/hostdb/P_HostDBProcessor.h | 3 ---
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc
index a1e8d32623..351dc70343 100644
--- a/src/iocore/hostdb/HostDB.cc
+++ b/src/iocore/hostdb/HostDB.cc
@@ -366,6 +366,21 @@ HostDBProcessor::init()
REC_EstablishStaticConfigInt32U(hostdb_ip_fail_timeout_interval, "proxy.config.hostdb.fail.timeout");
REC_EstablishStaticConfigInt32U(hostdb_serve_stale_but_revalidate, "proxy.config.hostdb.serve_stale_for");
REC_EstablishStaticConfigInt32U(hostdb_round_robin_max_count, "proxy.config.hostdb.round_robin_max_count");
+ const char *interval_config = "proxy.config.hostdb.host_file.interval";
+ {
+ RecInt tmp_interval{};
+
+ REC_ReadConfigInteger(tmp_interval, interval_config);
+ hostdb_hostfile_check_interval = std::chrono::seconds(tmp_interval);
+ }
+ RecRegisterConfigUpdateCb(
+ interval_config,
+ [&](const char *, RecDataT, RecData data, void *) {
+ hostdb_hostfile_check_interval = std::chrono::seconds(data.rec_int);
+
+ return REC_ERR_OKAY;
+ },
+ nullptr);
//
// Initialize hostdb_current_timestamp which is our cached version of
@@ -376,7 +391,6 @@ HostDBProcessor::init()
HostDBContinuation *b = hostDBContAllocator.alloc();
SET_CONTINUATION_HANDLER(b, &HostDBContinuation::backgroundEvent);
b->mutex = new_ProxyMutex();
- b->updateHostFileConfig();
eventProcessor.schedule_every(b, HRTIME_SECONDS(1), ET_DNS);
return 0;
@@ -1330,15 +1344,6 @@ HostDBContinuation::do_dns()
}
}
-void
-HostDBContinuation::updateHostFileConfig()
-{
- RecInt tmp_interval{};
-
- REC_ReadConfigInteger(tmp_interval, "proxy.config.hostdb.host_file.interval");
- hostdb_hostfile_check_interval = std::chrono::seconds(tmp_interval);
-}
-
//
// Background event
// Increment the hostdb_current_timestamp which functions as our cached version
@@ -1360,7 +1365,6 @@ HostDBContinuation::backgroundEvent(int /* event ATS_UNUSED */, Event * /* e ATS
bool update_p = false; // do we need to reparse the file and update?
char path[PATH_NAME_MAX];
- updateHostFileConfig();
REC_ReadConfigString(path, "proxy.config.hostdb.host_file.path", sizeof(path));
if (0 != strcasecmp(hostdb_hostfile_path.string(), path)) {
Dbg(dbg_ctl_hostdb, "%s",
diff --git a/src/iocore/hostdb/P_HostDBProcessor.h b/src/iocore/hostdb/P_HostDBProcessor.h
index c47e37c0cf..c7652e2224 100644
--- a/src/iocore/hostdb/P_HostDBProcessor.h
+++ b/src/iocore/hostdb/P_HostDBProcessor.h
@@ -235,9 +235,6 @@ struct HostDBContinuation : public Continuation {
int retryEvent(int event, Event *e);
int setbyEvent(int event, Event *e);
- // update the host file config variables
- void updateHostFileConfig();
-
/// Recompute the hash and update ancillary values.
void refresh_hash();
void do_dns();