Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
42 changes: 16 additions & 26 deletions cmd/traffic_manager/traffic_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,38 +616,27 @@ main(int argc, const char **argv)
RecLocalStart(configFiles);

/* Update cmd line overrides/environmental overrides/etc */
if (tsArgs) { /* Passed command line args for proxy */
ats_free(lmgmt->proxy_options);
lmgmt->proxy_options = tsArgs;
mgmt_log("[main] Traffic Server Args: '%s'\n", lmgmt->proxy_options);
}
if (tsArgs) /* Passed command line args for proxy */
callback_proxy_options.push_back(ats_strdup(tsArgs));

// we must pass in bind_stdout and bind_stderr values to TS
// we do it so TS is able to create BaseLogFiles for each value
// we must give bind_stdout and bind_stderr values to callback_proxy_options
// so LocalManager can start up TS with the correct options
//
// TS needs them to be able to create BaseLogFiles for each value
if (*bind_stdout != 0) {
callback_proxy_options.push_back(ats_strdup(TM_OPT_BIND_STDOUT));
char *bind_stdout_opt = new char[strlen("--") + strlen(TM_OPT_BIND_STDOUT)];
strcpy(bind_stdout_opt, "--");
strcat(bind_stdout_opt, TM_OPT_BIND_STDOUT);
callback_proxy_options.push_back(bind_stdout_opt);
callback_proxy_options.push_back(ats_strdup(bind_stdout));

size_t l = strlen(lmgmt->proxy_options);
size_t n = 3 /* " --" */
+ sizeof(TM_OPT_BIND_STDOUT) /* nul accounted for here */
+ 1 /* space */
+ strlen(bind_stdout);
lmgmt->proxy_options = static_cast<char *>(ats_realloc(lmgmt->proxy_options, n + l));
snprintf(lmgmt->proxy_options + l, n, " --%s %s", TM_OPT_BIND_STDOUT, bind_stdout);
}

if (*bind_stderr != 0) {
callback_proxy_options.push_back(ats_strdup(TM_OPT_BIND_STDERR));
char *bind_stderr_opt = new char[strlen("--") + strlen(TM_OPT_BIND_STDERR)];
strcpy(bind_stderr_opt, "--");
strcat(bind_stderr_opt, TM_OPT_BIND_STDERR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foo.push_back("--" TM_OPT_BIND_STDERR")

callback_proxy_options.push_back(bind_stderr_opt);
callback_proxy_options.push_back(ats_strdup(bind_stderr));

size_t l = strlen(lmgmt->proxy_options);
size_t n = 3 /* space dash dash */
+ sizeof(TM_OPT_BIND_STDERR) /* nul accounted for here */
+ 1 /* space */
+ strlen(bind_stderr);
lmgmt->proxy_options = static_cast<char *>(ats_realloc(lmgmt->proxy_options, n + l));
snprintf(lmgmt->proxy_options + l, n, " --%s %s", TM_OPT_BIND_STDERR, bind_stderr);
}

// If there exist proxy options we want CoreAPI to have, we set the callback
Expand Down Expand Up @@ -835,10 +824,11 @@ main(int argc, const char **argv)
} else {
sleep_time = 1;
}
if (lmgmt->startProxy()) {
if (ProxyStateSet(TS_PROXY_ON, TS_CACHE_CLEAR_NONE) == TS_ERR_OKAY) {
just_started = 0;
sleep_time = 0;
} else {
mgmt_log("in ProxyStateSet else branch");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: remove this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please :)

just_started++;
}
} else { /* Give the proxy a chance to fire up */
Expand Down
1 change: 1 addition & 0 deletions mgmt/api/CoreAPI.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ ProxyStateSet(TSProxyStateT state, TSCacheClearT clear)
mgmt_log("[ProxyStateSet] Traffic Server Args: '%s'\n", lmgmt->proxy_options);

lmgmt->run_proxy = true;
lmgmt->startProxy();
lmgmt->listenForProxy();

do {
Expand Down