Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions proxy/http/remap/RemapConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

static bool remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti);

load_remap_file_func load_remap_file_cb = nullptr;

/**
Returns the length of the URL.

Expand Down Expand Up @@ -286,17 +288,17 @@ parse_remap_fragment(const char *path, BUILD_TABLE_INFO *bti, char *errbuf, size
nbti.rules_list = bti->rules_list;
nbti.rewrite = bti->rewrite;

// XXX at this point, we need to register the included file(s) with the management subsystem
// so that we can correctly reload them when they change. Otherwise, the operator will have to
// touch remap.config before reloading the configuration.

Debug("url_rewrite", "[%s] including remap configuration from %s", __func__, (const char *)path);
success = remap_parse_config_bti(path, &nbti);

// The sub-parse might have updated the rules list, so push it up to the parent parse.
bti->rules_list = nbti.rules_list;

if (!success) {
if (success) {
// register the included file with the management subsystem so that we can correctly
// reload them when they change
load_remap_file_cb((const char *)path);
} else {
snprintf(errbuf, errbufsize, "failed to parse included file %s", path);
return (const char *)errbuf;
}
Expand Down
4 changes: 4 additions & 0 deletions proxy/http/remap/RemapConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ unsigned long remap_check_option(const char **argv, int argc, unsigned long find
const char **argptr = nullptr);

bool remap_parse_config(const char *path, UrlRewrite *rewrite);

typedef void (*load_remap_file_func)(const char *);

extern load_remap_file_func load_remap_file_cb;
12 changes: 12 additions & 0 deletions src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ extern "C" int plock(int);
#include "Plugin.h"
#include "DiagsConfig.h"
#include "CoreUtils.h"
#include "RemapConfig.h"
#include "RemapProcessor.h"
#include "I_Tasks.h"
#include "InkAPIInternal.h"
Expand Down Expand Up @@ -119,6 +120,7 @@ static void *mgmt_storage_device_cmd_callback(void *x, char *data, int len);
static void *mgmt_lifecycle_msg_callback(void *x, char *data, int len);
static void init_ssl_ctx_callback(void *ctx, bool server);
static void load_ssl_file_callback(const char *ssl_file, unsigned int options);
static void load_remap_file_callback(const char *remap_file);

// We need these two to be accessible somewhere else now
int num_of_net_threads = ink_number_of_processors();
Expand Down Expand Up @@ -1707,11 +1709,15 @@ main(int /* argc ATS_UNUSED */, const char **argv)
::exit(0);
}

// setup callback for tracking remap included files
load_remap_file_cb = load_remap_file_callback;

// We need to do this early so we can initialize the Machine
// singleton, which depends on configuration values loaded in this.
// We want to initialize Machine as early as possible because it
// has other dependencies. Hopefully not in prep_HttpProxyServer().
HttpConfig::startup();

/* Set up the machine with the outbound address if that's set,
or the inbound address if set, otherwise let it default.
*/
Expand Down Expand Up @@ -2095,3 +2101,9 @@ load_ssl_file_callback(const char *ssl_file, unsigned int options)
{
pmgmt->signalConfigFileChild("ssl_multicert.config", ssl_file, options);
}

static void
load_remap_file_callback(const char *remap_file)
{
pmgmt->signalConfigFileChild("remap.config", remap_file, CONFIG_FLAG_UNVERSIONED);
}