Skip to content

Commit

Permalink
bsock: improved socket close
Browse files Browse the repository at this point in the history
- removed obvious comments
- check for valid socket descriptor number before closing
  • Loading branch information
franku committed Aug 16, 2018
1 parent e0826ac commit 6a42056
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions core/src/lib/bsock_tcp.cc
Expand Up @@ -906,26 +906,24 @@ int BareosSocketTCP::WaitDataIntr(int sec, int usec)

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

if (!cloned_) {
/*
* Shutdown tls cleanly.
*/
if (tls_conn) {
tls_conn->TlsBsockShutdown(this);
CloseTlsConnectionAndFreeMemory();
}
ClearLocking();

if (tls_conn) {
CloseTlsConnectionAndFreeMemory();
}

if (fd_ >= 0) {
if (IsTimedOut()) {
shutdown(fd_, SHUT_RDWR); /* discard any pending I/O */
/* discard any pending I/O */
shutdown(fd_, SHUT_RDWR);
}
socketClose(fd_); /* normal close */
socketClose(fd_);
fd_ = -1;
}

return;
}

void BareosSocketTCP::destroy()
Expand Down

0 comments on commit 6a42056

Please sign in to comment.