Skip to content

Commit

Permalink
dird: reset or use client connection handshake modes saved in the cli…
Browse files Browse the repository at this point in the history
…ent-config

- reset all modes to kUndefined after reloading the config
- safe the successful connection mode in the config
- use the last saved connection mode for future connections
- adapted some comments
  • Loading branch information
franku committed Sep 23, 2018
1 parent 419a438 commit 2ace092
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 14 additions & 0 deletions core/src/dird/dird_conf.cc
Expand Up @@ -3794,6 +3794,18 @@ static void PrintConfigCb(ResourceItem *items, int i, PoolMem &cfg_str, bool hid
}
}

static void ResetAllClientConnectionHandshakeModes(ConfigurationParser &my_config)
{
CommonResourceHeader *header = nullptr;
do {
header = my_config.GetNextRes(R_CLIENT, header);
ClientResource *client = reinterpret_cast<ClientResource*>(header);
if (client) {
client->connection_successful_handshake_ = ClientConnectionHandshakeMode::kUndefined;
}
} while (header);
}

static void ConfigReadyCallback(ConfigurationParser &my_config)
{
CreateAndAddUserAgentConsoleResource(my_config);
Expand All @@ -3805,6 +3817,8 @@ static void ConfigReadyCallback(ConfigurationParser &my_config)
{R_MSGS, "R_MSGS"}, {R_COUNTER, "R_COUNTER"}, {R_PROFILE, "R_PROFILE"},
{R_CONSOLE, "R_CONSOLE"}, {R_DEVICE, "R_DEVICE"}};
my_config.InitializeQualifiedResourceNameTypeConverter(map);

ResetAllClientConnectionHandshakeModes(my_config);
}

static bool AddResourceCopyToEndOfChain(UnionOfResources *res_to_add, int type)
Expand Down
14 changes: 10 additions & 4 deletions core/src/dird/fd_cmds.cc
Expand Up @@ -165,10 +165,16 @@ bool ConnectToFileDaemon(JobControlRecord *jcr, int retry_interval, int max_retr
bool tcp_connect_failed = false;
int connect_tries = 3; /* as a finish-hook for the UseWaitingClient mechanism */

/* try the connection mode in case a client that cannot do Tls
* immediately without cleartext md5-handshake first */
jcr->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst;
jcr->res.client->connection_successful_handshake_ = ClientConnectionHandshakeMode::kUndefined;
/* try the connection modes starting with tls directly,
* in case there is a client that cannot do Tls immediately then
* fall back to cleartext md5-handshake */
if (jcr->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined
|| jcr->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) {
jcr->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst;
} else {
/* if there is a stored mode from a previous connection then use this */
jcr->connection_handshake_try_ = jcr->res.client->connection_successful_handshake_;
}

do { /* while (tcp_connect_failed ...) */
/* connect the tcp socket */
Expand Down

0 comments on commit 2ace092

Please sign in to comment.