This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 98be1f4 Do not reload remap.config when calling verify_config
98be1f4 is described below
commit 98be1f45a9206c8f388a01cd325d1594437caedd
Author: Emanuele Rocca <[email protected]>
AuthorDate: Mon Nov 19 10:39:11 2018 +0100
Do not reload remap.config when calling verify_config
Calling `verify_config` should not swap the currently loaded
configuration, but simply check whether the configuration files are
valid.
This fixes issue #4466
---
proxy/ReverseProxy.cc | 17 +++++++++++++++--
proxy/ReverseProxy.h | 1 +
src/traffic_server/traffic_server.cc | 2 +-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/proxy/ReverseProxy.cc b/proxy/ReverseProxy.cc
index 81f18a5..99c7677 100644
--- a/proxy/ReverseProxy.cc
+++ b/proxy/ReverseProxy.cc
@@ -117,6 +117,12 @@ struct UR_UpdateContinuation : public Continuation {
}
};
+bool
+urlRewriteVerify()
+{
+ return UrlRewrite().is_valid();
+}
+
/**
Called when the remap.config file changes. Since it called infrequently,
we do the load of new file as blocking I/O and lock aquire is also
@@ -126,7 +132,7 @@ struct UR_UpdateContinuation : public Continuation {
bool
reloadUrlRewrite()
{
- UrlRewrite *newTable;
+ UrlRewrite *newTable, *oldTable;
Debug("url_rewrite", "remap.config updated, reloading...");
newTable = new UrlRewrite();
@@ -136,7 +142,14 @@ reloadUrlRewrite()
// Hold at least one lease, until we reload the configuration
newTable->acquire();
- ink_atomic_swap(&rewrite_table, newTable)->release(); // Swap
configurations, and release the old one
+ // Swap configurations
+ oldTable = ink_atomic_swap(&rewrite_table, newTable);
+
+ ink_assert(oldTable != nullptr);
+
+ // Release the old one
+ oldTable->release();
+
Debug("url_rewrite", "%s", msg);
Note("%s", msg);
return true;
diff --git a/proxy/ReverseProxy.h b/proxy/ReverseProxy.h
index 0ba5bc3..dd205cf 100644
--- a/proxy/ReverseProxy.h
+++ b/proxy/ReverseProxy.h
@@ -56,5 +56,6 @@ bool response_url_remap(HTTPHdr *response_header, UrlRewrite
*table);
// Reload Functions
bool reloadUrlRewrite();
+bool urlRewriteVerify();
int url_rewrite_CB(const char *name, RecDataT data_type, RecData data, void
*cookie);
diff --git a/src/traffic_server/traffic_server.cc
b/src/traffic_server/traffic_server.cc
index 3080045..a69aeec 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -848,7 +848,7 @@ cmd_verify(char * /* cmd ATS_UNUSED */)
Layout::get()->update_sysconfdir(conf_dir);
}
- if (!reloadUrlRewrite()) {
+ if (!urlRewriteVerify()) {
exitStatus |= (1 << 0);
fprintf(stderr, "ERROR: Failed to load remap.config, exitStatus %d\n\n",
exitStatus);
} else {