Skip to content

Commit

Permalink
bnet: renamed and changed scope of network dump functions
Browse files Browse the repository at this point in the history
- the unique pointer to the network dump interface should be protected
  and initialized by a member function
- creation of the network dump interface should be called from the
  protected initializer function
  • Loading branch information
franku committed Jul 4, 2019
1 parent 81793c9 commit 3260d21
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion core/src/console/connect_to_director.cc
Expand Up @@ -70,7 +70,7 @@ BareosSocket* ConnectToDirector(JobControlRecord& jcr,
local_tls_resource = director_resource;
}

UA_sock->FillBSockWithConnectedDaemonInformation(own_resource,
UA_sock->EnableNetworkMessagesDump(own_resource,
director_resource);

if (local_tls_resource->IsTlsConfigured()) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/fd_cmds.cc
Expand Up @@ -268,7 +268,7 @@ bool ConnectToFileDaemon(JobControlRecord* jcr,

if (jcr->file_bsock) {
jcr->setJobStatus(JS_Running);
jcr->file_bsock->FillBSockWithConnectedDaemonInformation(me,
jcr->file_bsock->EnableNetworkMessagesDump(me,
jcr->res.client);
if (AuthenticateWithFileDaemon(jcr)) {
success = true;
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/sd_cmds.cc
Expand Up @@ -143,7 +143,7 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr,
}
}

sd->FillBSockWithConnectedDaemonInformation(me, store);
sd->EnableNetworkMessagesDump(me, store);

if (!AuthenticateWithStorageDaemon(sd.get(), jcr, store)) {
sd->close();
Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/socket_server.cc
Expand Up @@ -121,11 +121,11 @@ static void* HandleConnectionRequest(ConfigurationParser* config, void* arg)
(sscanf(bs->msg, hello_client, name) == 1)) {
Dmsg1(110, "Got a FD connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_CLIENT);
bs->EnableNetworkMessagesDump(*my_config, R_CLIENT);
return HandleFiledConnection(client_connections, bs, name,
fd_protocol_version);
}
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_CONSOLE);
bs->EnableNetworkMessagesDump(*my_config, R_CONSOLE);
return HandleUserAgentClientRequest(bs);
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/filed/dir_cmd.cc
Expand Up @@ -1694,7 +1694,7 @@ static bool StorageCmd(JobControlRecord* jcr)
}
}

storage_daemon_socket->FillBSockWithConnectedDaemonInformation(*my_config,
storage_daemon_socket->EnableNetworkMessagesDump(*my_config,
R_STORAGE);

storage_daemon_socket->fsend("Hello Start Job %s\n", jcr->Job);
Expand Down Expand Up @@ -2321,7 +2321,7 @@ static BareosSocket* connect_to_director(JobControlRecord* jcr,
}
}

director_socket->FillBSockWithConnectedDaemonInformation(me, dir_res);
director_socket->EnableNetworkMessagesDump(me, dir_res);

Dmsg1(10, "Opened connection with Director %s\n", dir_res->resource_name_);
jcr->dir_bsock = director_socket.get();
Expand Down
4 changes: 2 additions & 2 deletions core/src/filed/socket_server.cc
Expand Up @@ -88,7 +88,7 @@ static void* HandleConnectionRequest(ConfigurationParser* config, void* arg)
if (bstrncmp(bs->msg, "Hello Director", 14)) {
Dmsg1(110, "Got a DIR connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_DIRECTOR);
bs->EnableNetworkMessagesDump(*my_config, R_DIRECTOR);
return handle_director_connection(bs);
}

Expand All @@ -98,7 +98,7 @@ static void* HandleConnectionRequest(ConfigurationParser* config, void* arg)
if (bstrncmp(bs->msg, "Hello Storage", 13)) {
Dmsg1(110, "Got a SD connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_STORAGE);
bs->EnableNetworkMessagesDump(*my_config, R_STORAGE);
return handle_stored_connection(bs);
}

Expand Down
7 changes: 3 additions & 4 deletions core/src/lib/bsock.cc
Expand Up @@ -802,7 +802,7 @@ void BareosSocket::ControlBwlimit(int bytes)
}
}

void BareosSocket::FillBSockWithConnectedDaemonInformation(
void BareosSocket::EnableNetworkMessagesDump(
const ConfigurationParser& my_config,
int destination_rcode)
{
Expand All @@ -811,9 +811,8 @@ void BareosSocket::FillBSockWithConnectedDaemonInformation(
*my_config.GetQualifiedResourceNameTypeConverter()));
}

void BareosSocket::FillBSockWithConnectedDaemonInformation(
const BareosResource* me,
const BareosResource* destination)
void BareosSocket::EnableNetworkMessagesDump(const BareosResource* me,
const BareosResource* destination)
{
SetNwdump(BnetDump::Create(me, destination));
}
20 changes: 9 additions & 11 deletions core/src/lib/bsock.h
Expand Up @@ -84,11 +84,6 @@ class BareosSocket {
struct sockaddr_in peer_addr; /* Peer's IP address */
void SetTlsEstablished() { tls_established_ = true; }
bool TlsEstablished() const { return tls_established_; }
void SetNwdump(std::unique_ptr<BnetDump>&& nwdump)
{
assert(!bnet_dump_);
bnet_dump_ = std::move(nwdump);
}
std::shared_ptr<Tls> tls_conn; /* Associated tls connection */
std::unique_ptr<Tls> tls_conn_init; /* during initialization */
BareosVersionNumber connected_daemon_version_;
Expand Down Expand Up @@ -142,6 +137,11 @@ class BareosSocket {
const char* password,
JobControlRecord* jcr);
void ParameterizeTlsCert(Tls* tls_conn, TlsResource* tls_resource);
void SetNwdump(std::unique_ptr<BnetDump>&& nwdump)
{
assert(!bnet_dump_);
bnet_dump_ = std::move(nwdump);
}

public:
BareosSocket();
Expand Down Expand Up @@ -273,12 +273,10 @@ class BareosSocket {
void StopTimer() { StopBsockTimer(tid_); }
void LockMutex();
void UnlockMutex();
void FillBSockWithConnectedDaemonInformation(
const ConfigurationParser& my_config,
int destination_rcode);
void FillBSockWithConnectedDaemonInformation(
const BareosResource* me,
const BareosResource* destination);
void EnableNetworkMessagesDump(const ConfigurationParser& my_config,
int destination_rcode);
void EnableNetworkMessagesDump(const BareosResource* me,
const BareosResource* destination);
};

/**
Expand Down
6 changes: 3 additions & 3 deletions core/src/stored/dir_cmd.cc
Expand Up @@ -1695,8 +1695,8 @@ static bool ReplicateCmd(JobControlRecord* jcr)
}

jcr->store_bsock = storage_daemon_socket.get();
jcr->store_bsock->SetNwdump(BnetDump::Create(
me, R_STORAGE, *my_config->GetQualifiedResourceNameTypeConverter()));
jcr->store_bsock->EnableNetworkMessagesDump(*my_config,
R_STORAGE);

storage_daemon_socket->fsend("Hello Start Storage Job %s\n", JobName);

Expand Down Expand Up @@ -1786,7 +1786,7 @@ static bool PassiveCmd(JobControlRecord* jcr)
}
}

fd->FillBSockWithConnectedDaemonInformation(*my_config, R_CLIENT);
fd->EnableNetworkMessagesDump(*my_config, R_CLIENT);

jcr->file_bsock = fd;
fd->fsend("Hello Storage calling Start Job %s\n", jcr->Job);
Expand Down
6 changes: 3 additions & 3 deletions core/src/stored/socket_server.cc
Expand Up @@ -107,7 +107,7 @@ void* HandleConnectionRequest(ConfigurationParser* config, void* arg)
if (sscanf(bs->msg, "Hello Start Job %127s", name) == 1) {
Dmsg1(110, "Got a FD connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_CLIENT);
bs->EnableNetworkMessagesDump(*my_config, R_CLIENT);
return HandleFiledConnection(bs, name);
}

Expand All @@ -117,14 +117,14 @@ void* HandleConnectionRequest(ConfigurationParser* config, void* arg)
if (sscanf(bs->msg, "Hello Start Storage Job %127s", name) == 1) {
Dmsg1(110, "Got a SD connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));
bs->FillBSockWithConnectedDaemonInformation(*my_config, R_STORAGE);
bs->EnableNetworkMessagesDump(*my_config, R_STORAGE);
return handle_stored_connection(bs, name);
}

Dmsg1(110, "Got a DIR connection at %s\n",
bstrftimes(tbuf, sizeof(tbuf), (utime_t)time(NULL)));

bs->FillBSockWithConnectedDaemonInformation(*my_config, R_DIRECTOR);
bs->EnableNetworkMessagesDump(*my_config, R_DIRECTOR);

return HandleDirectorConnection(bs);
}
Expand Down

0 comments on commit 3260d21

Please sign in to comment.