Skip to content

Commit

Permalink
bsock: do not reset tls connection from a cloned bsock
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Oct 2, 2018
1 parent 8e6e279 commit db4474b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
24 changes: 15 additions & 9 deletions core/src/lib/bsock.cc
Expand Up @@ -125,15 +125,17 @@ BareosSocket::~BareosSocket() { Dmsg0(100, "Destruct BareosSocket\n"); }

void BareosSocket::CloseTlsConnectionAndFreeMemory()
{
LockMutex();
if (tls_conn && !tls_conn_init) {
tls_conn->TlsBsockShutdown(this);
tls_conn.reset();
} else if (tls_conn_init) {
tls_conn_init->TlsBsockShutdown(this);
tls_conn_init.reset();
if (!cloned_) {
LockMutex();
if (tls_conn && !tls_conn_init) {
tls_conn->TlsBsockShutdown(this);
tls_conn.reset();
} else if (tls_conn_init) {
tls_conn_init->TlsBsockShutdown(this);
tls_conn_init.reset();
}
UnlockMutex();
}
UnlockMutex();
}

/**
Expand Down Expand Up @@ -169,7 +171,11 @@ bool BareosSocket::SetLocking()

void BareosSocket::ClearLocking()
{
if (mutex_) { mutex_.reset(); }
if (!cloned_) {
if (mutex_) {
mutex_.reset();
}
}
}

void BareosSocket::LockMutex()
Expand Down
10 changes: 3 additions & 7 deletions core/src/lib/bsock_tcp.cc
Expand Up @@ -906,13 +906,9 @@ int BareosSocketTCP::WaitDataIntr(int sec, int usec)

void BareosSocketTCP::close()
{
if (!cloned_) {
ClearLocking();

if (tls_conn || tls_conn_init) {
CloseTlsConnectionAndFreeMemory();
}
}
/* if not cloned */
ClearLocking();
CloseTlsConnectionAndFreeMemory();

if (fd_ >= 0) {
if (!cloned_) {
Expand Down

0 comments on commit db4474b

Please sign in to comment.