Fix ODR violations

This commit is contained in:
Fred Nicolson 2019-05-01 10:27:44 +01:00
parent c23a77d4cc
commit abd6dbebad
No known key found for this signature in database
GPG Key ID: 78C1DD87B47797D2
4 changed files with 30 additions and 24 deletions

View File

@ -103,12 +103,7 @@ namespace fr
* *
* @return The socket's descriptor. -1 indicates no connection. * @return The socket's descriptor. -1 indicates no connection.
*/ */
inline int32_t get_socket_descriptor() const noexcept override int32_t get_socket_descriptor() const override;
{
if(!ssl_socket_descriptor)
return -1;
return ssl_socket_descriptor->fd;
}
/*! /*!
* Sets if the socket should block or not. * Sets if the socket should block or not.
@ -119,18 +114,7 @@ namespace fr
* 'SSLError' on failure. * 'SSLError' on failure.
* 'Success' on success. * 'Success' on success.
*/ */
inline fr::Socket::Status set_blocking(bool should_block) override 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;
}
/*! /*!
* Checks if the socket is blocking * Checks if the socket is blocking
@ -147,10 +131,7 @@ namespace fr
* *
* @return True if it's connected. False otherwise. * @return True if it's connected. False otherwise.
*/ */
inline bool connected() const noexcept final bool connected() const final;
{
return ssl_socket_descriptor && ssl_socket_descriptor->fd > -1;
}
private: private:

View File

@ -103,7 +103,7 @@ namespace fr
* *
* @return True if connected, false otherwise * @return True if connected, false otherwise
*/ */
bool connected() const noexcept override; bool connected() const override;
/*! /*!
* Gets the underlying socket descriptor. * Gets the underlying socket descriptor.

View File

@ -243,6 +243,19 @@ namespace fr
should_verify = should_verify_; 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() void SSLSocket::reconfigure_socket()
{ {
if(!connected()) if(!connected())
@ -264,4 +277,16 @@ namespace fr
setsockopt(get_socket_descriptor(), SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_dword, sizeof timeout_dword); setsockopt(get_socket_descriptor(), SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout_dword, sizeof timeout_dword);
#endif #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;
}
} }

View File

@ -248,7 +248,7 @@ namespace fr
#endif #endif
} }
bool TcpSocket::connected() const noexcept bool TcpSocket::connected() const
{ {
return socket_descriptor > -1; return socket_descriptor > -1;
} }