Skip to content

Make sure that TLSSocketWrapper::close() is called before the transport is destroyed. #8613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2018
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
9 changes: 9 additions & 0 deletions features/netsocket/TLSSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ nsapi_error_t TLSSocket::connect(const char *host, uint16_t port)
return TLSSocketWrapper::do_handshake();
}

TLSSocket::~TLSSocket()
{
/* Transport is a member of TLSSocket which is derived from TLSSocketWrapper.
* Make sure that TLSSocketWrapper::close() is called before the transport is
* destroyed.
*/
close();
}

#endif // MBEDTLS_SSL_CLI_C
4 changes: 4 additions & 0 deletions features/netsocket/TLSSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class TLSSocket : public TLSSocketWrapper {
*/
TLSSocket() : TLSSocketWrapper(&tcp_socket) {}

/** Destroy the TLSSocket and closes the transport.
*/
virtual ~TLSSocket();

/** Create a socket on a network interface
*
* Creates and opens a socket on the network stack of the given
Expand Down