Skip to content
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
5 changes: 3 additions & 2 deletions kmipclient/include/kmipclient/NetClient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef KMIP_NET_CLIENT_HPP
#define KMIP_NET_CLIENT_HPP

#include <atomic>
#include <cstdint>
#include <span>
#include <string>
Expand Down Expand Up @@ -99,7 +100,7 @@ namespace kmipclient {
* @brief Checks whether a connection is currently established.
* @return true when connected, false otherwise.
*/
[[nodiscard]] bool is_connected() const { return m_isConnected; }
[[nodiscard]] bool is_connected() const noexcept { return m_isConnected; }
/**
* @brief Sends bytes over the established connection.
* @param data Source buffer.
Expand All @@ -122,7 +123,7 @@ namespace kmipclient {
std::string m_serverCaCertificateFn;
int m_timeout_ms;
TlsVerificationOptions m_tls_verification{};
bool m_isConnected = false;
std::atomic<bool> m_isConnected{false};
};
} // namespace kmipclient
#endif // KMIP_NET_CLIENT_HPP
18 changes: 3 additions & 15 deletions kmipclient/src/NetClientOpenSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,7 @@ namespace kmipclient {
}

NetClientOpenSSL::~NetClientOpenSSL() {
// Avoid calling virtual methods from destructor.
if (bio_) {
bio_.reset();
}
if (ctx_) {
ctx_.reset();
}
m_isConnected = false;
close();
}

bool NetClientOpenSSL::connect() {
Expand Down Expand Up @@ -477,14 +470,9 @@ namespace kmipclient {
}

void NetClientOpenSSL::close() {
if (bio_) {
// BIO_free_all is called by unique_ptr reset
bio_.reset();
}
if (ctx_) {
ctx_.reset();
}
m_isConnected = false;
bio_.reset();
ctx_.reset();
}

int NetClientOpenSSL::send(std::span<const std::uint8_t> data) {
Expand Down
Loading