From abd6dbebadc8365239a72602d858b0906110d596 Mon Sep 17 00:00:00 2001 From: Fred Nicolson Date: Wed, 1 May 2019 10:27:44 +0100 Subject: [PATCH] Fix ODR violations --- include/frnetlib/SSLSocket.h | 25 +++---------------------- include/frnetlib/TcpSocket.h | 2 +- src/SSLSocket.cpp | 25 +++++++++++++++++++++++++ src/TcpSocket.cpp | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/include/frnetlib/SSLSocket.h b/include/frnetlib/SSLSocket.h index 8e613e7..322d205 100644 --- a/include/frnetlib/SSLSocket.h +++ b/include/frnetlib/SSLSocket.h @@ -103,12 +103,7 @@ namespace fr * * @return The socket's descriptor. -1 indicates no connection. */ - inline int32_t get_socket_descriptor() const noexcept override - { - if(!ssl_socket_descriptor) - return -1; - return ssl_socket_descriptor->fd; - } + int32_t get_socket_descriptor() const override; /*! * Sets if the socket should block or not. @@ -119,18 +114,7 @@ namespace fr * 'SSLError' on failure. * 'Success' on success. */ - inline fr::Socket::Status set_blocking(bool should_block) override - { - int ret = mbedtls_net_set_block(ssl_socket_descriptor.get()); - if(ret != 0) - { - errno = ret; - return fr::Socket::SSLError; - } - - is_blocking = should_block; - return fr::Socket::Success; - } + fr::Socket::Status set_blocking(bool should_block) override; /*! * Checks if the socket is blocking @@ -147,10 +131,7 @@ namespace fr * * @return True if it's connected. False otherwise. */ - inline bool connected() const noexcept final - { - return ssl_socket_descriptor && ssl_socket_descriptor->fd > -1; - } + bool connected() const final; private: diff --git a/include/frnetlib/TcpSocket.h b/include/frnetlib/TcpSocket.h index 10df49d..10d72ef 100644 --- a/include/frnetlib/TcpSocket.h +++ b/include/frnetlib/TcpSocket.h @@ -103,7 +103,7 @@ namespace fr * * @return True if connected, false otherwise */ - bool connected() const noexcept override; + bool connected() const override; /*! * Gets the underlying socket descriptor. diff --git a/src/SSLSocket.cpp b/src/SSLSocket.cpp index e94c2b0..d4560f2 100644 --- a/src/SSLSocket.cpp +++ b/src/SSLSocket.cpp @@ -243,6 +243,19 @@ namespace fr should_verify = should_verify_; } + fr::Socket::Status SSLSocket::set_blocking(bool should_block) + { + int ret = mbedtls_net_set_block(ssl_socket_descriptor.get()); + if(ret != 0) + { + errno = ret; + return fr::Socket::SSLError; + } + + is_blocking = should_block; + return fr::Socket::Success; + } + void SSLSocket::reconfigure_socket() { if(!connected()) @@ -264,4 +277,16 @@ namespace fr setsockopt(get_socket_descriptor(), SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_dword, sizeof timeout_dword); #endif } + + int32_t SSLSocket::get_socket_descriptor() const + { + if(!ssl_socket_descriptor) + return -1; + return ssl_socket_descriptor->fd; + } + + bool SSLSocket::connected() const + { + return ssl_socket_descriptor && ssl_socket_descriptor->fd > -1; + } } \ No newline at end of file diff --git a/src/TcpSocket.cpp b/src/TcpSocket.cpp index e3b4743..9432a2f 100644 --- a/src/TcpSocket.cpp +++ b/src/TcpSocket.cpp @@ -248,7 +248,7 @@ namespace fr #endif } - bool TcpSocket::connected() const noexcept + bool TcpSocket::connected() const { return socket_descriptor > -1; }