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
21 changes: 18 additions & 3 deletions include/tscore/TSSystemState.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ class TSSystemState
{
private:
struct Data {
bool ssl_handshaking_stopped;
bool event_system_shut_down;
bool draining;
bool initializing = true;
bool ssl_handshaking_stopped = false;
bool event_system_shut_down = false;
bool draining = false;
};

public:
static bool
is_initializing()
{
return unlikely(_instance().initializing);
}

static bool
is_ssl_handshaking_stopped()
{
Expand All @@ -58,6 +65,14 @@ class TSSystemState
return unlikely(_instance().draining);
}

static void
initialization_done()
{
ink_assert(_instance().initializing);

_instance().initializing = false;
}

static void
stop_ssl_handshaking()
{
Expand Down
11 changes: 9 additions & 2 deletions iocore/net/SSLSNIConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "tscpp/util/TextView.h"
#include "tscore/I_Layout.h"
#include <sstream>
#include <utility>
#include <pcre.h>

static constexpr int OVECSIZE{30};
Expand Down Expand Up @@ -166,13 +167,19 @@ SNIConfigParams::Initialize()
return 1;
}

ts::Errata zret = Y_sni.loader(sni_filename);
YamlSNIConfig Y_sni_tmp;
ts::Errata zret = Y_sni_tmp.loader(sni_filename);
if (!zret.isOK()) {
std::stringstream errMsg;
errMsg << zret;
Error("%s failed to load: %s", sni_filename, errMsg.str().c_str());
if (TSSystemState::is_initializing()) {
Emergency("%s failed to load: %s", sni_filename, errMsg.str().c_str());
} else {
Error("%s failed to load: %s", sni_filename, errMsg.str().c_str());
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic may be common enough that we should add a new diag output call, perhaps InitEmergency(), that blocks startup if initializing, but simply logs an error otherwise.

return 1;
}
Y_sni = std::move(Y_sni_tmp);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this logic to make sure the static data remained the coherent, old version if an invalid sni.yaml was reloaded.


loadSNIConfig();
Note("%s finished loading", sni_filename);
Expand Down
2 changes: 2 additions & 0 deletions src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2224,6 +2224,8 @@ main(int /* argc ATS_UNUSED */, const char **argv)
}
#endif

TSSystemState::initialization_done();

while (!TSSystemState::is_event_system_shut_down()) {
sleep(1);
}
Expand Down