From d68e94e54bd96e87d754e878d84d73eaf1200236 Mon Sep 17 00:00:00 2001 From: bneradt Date: Wed, 20 Apr 2022 17:08:33 -0500 Subject: [PATCH] Revert remap.config loading changes Revert "Short circuit remap reload when a valid remap file is not specified (#7782)" This reverts commit d7847f23717d3a8be8341c244bbe1e27b2a6a77a. This is being reverted from 9.2.x because changing remap.config loading behavior was deemed too big a change to make within the 9.x releases. See the discussion in #8802. These remap.config changes will be pursued in the 10.x train. --- proxy/ReverseProxy.cc | 5 ++--- proxy/http/remap/RemapConfig.cc | 12 +++++++++--- proxy/http/remap/UrlRewrite.cc | 6 ++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/proxy/ReverseProxy.cc b/proxy/ReverseProxy.cc index c04f6cdfb04..f46955812bb 100644 --- a/proxy/ReverseProxy.cc +++ b/proxy/ReverseProxy.cc @@ -67,10 +67,9 @@ init_reverse_proxy() Note("%s loading ...", ts::filename::REMAP); if (!rewrite_table->load()) { - Warning("%s failed to load", ts::filename::REMAP); - } else { - Note("%s finished loading", ts::filename::REMAP); + Fatal("%s failed to load", ts::filename::REMAP); } + Note("%s finished loading", ts::filename::REMAP); REC_RegisterConfigUpdateFunc("proxy.config.url_remap.filename", url_rewrite_CB, (void *)FILE_CHANGED); REC_RegisterConfigUpdateFunc("proxy.config.proxy_name", url_rewrite_CB, (void *)TSNAME_CHANGED); diff --git a/proxy/http/remap/RemapConfig.cc b/proxy/http/remap/RemapConfig.cc index 61afbd70221..5a2930aec72 100644 --- a/proxy/http/remap/RemapConfig.cc +++ b/proxy/http/remap/RemapConfig.cc @@ -944,9 +944,15 @@ remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti) std::error_code ec; std::string content{ts::file::load(ts::file::path{path}, ec)}; - if (ec.value()) { - Warning("Failed to open remapping configuration file %s - %s", path, strerror(ec.value())); - return false; + if (ec) { + switch (ec.value()) { + case ENOENT: + Warning("Can't open remapping configuration file %s - %s", path, strerror(ec.value())); + break; + default: + Error("Failed load remapping configuration file %s - %s", path, strerror(ec.value())); + return false; + } } Debug("url_rewrite", "[BuildTable] UrlRewrite::BuildTable()"); diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc index 96de22b3a14..e8ca255e083 100644 --- a/proxy/http/remap/UrlRewrite.cc +++ b/proxy/http/remap/UrlRewrite.cc @@ -698,11 +698,9 @@ UrlRewrite::BuildTable(const char *path) temporary_redirects.hash_lookup.reset(new URLTable); forward_mappings_with_recv_port.hash_lookup.reset(new URLTable); - int zret = 0; - if (!remap_parse_config(path, this)) { // XXX handle file reload error - zret = 3; + return 3; } // Destroy unused tables @@ -730,7 +728,7 @@ UrlRewrite::BuildTable(const char *path) forward_mappings_with_recv_port.hash_lookup.reset(nullptr); } - return zret; + return 0; } /**