[Libreoffice-commits] online.git: net/Socket.hpp net/SslSocket.hpp
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Tue Dec 10 11:45:43 UTC 2019
net/Socket.hpp | 3 ++-
net/SslSocket.hpp | 21 ++++++++++++++++-----
2 files changed, 18 insertions(+), 6 deletions(-)
New commits:
commit 1ff820de95b639895e5603a75553d61c79bedc3f
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Dec 10 11:11:20 2019 +0000
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Dec 10 11:45:13 2019 +0000
tdf#129306 SslSocket: handle EAGAIN properly.
Change-Id: I9fb3323b8d071fdc50399a67eb6b0aaeed9342b0
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 730f7194b..98479841b 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -831,7 +831,8 @@ public:
~StreamSocket()
{
- LOG_DBG("StreamSocket dtor #" << getFD());
+ LOG_DBG("StreamSocket dtor #" << getFD() << " with pending "
+ "write: " << _outBuffer.size() << ", read: " << _inBuffer.size());
if (!_closed)
{
diff --git a/net/SslSocket.hpp b/net/SslSocket.hpp
index de16fdf1d..ba9954f56 100644
--- a/net/SslSocket.hpp
+++ b/net/SslSocket.hpp
@@ -22,28 +22,30 @@ public:
SslStreamSocket(const int fd, bool isClient,
std::shared_ptr<SocketHandlerInterface> responseClient) :
StreamSocket(fd, isClient, std::move(responseClient)),
+ _bio(nullptr),
_ssl(nullptr),
_sslWantsTo(SslWantsTo::Neither),
_doHandshake(true)
{
LOG_DBG("SslStreamSocket ctor #" << fd);
- BIO* bio = BIO_new(BIO_s_socket());
- if (bio == nullptr)
+ _bio = BIO_new(BIO_s_socket());
+ if (_bio == nullptr)
{
throw std::runtime_error("Failed to create SSL BIO.");
}
- BIO_set_fd(bio, fd, BIO_NOCLOSE);
+ BIO_set_fd(_bio, fd, BIO_NOCLOSE);
_ssl = SslContext::newSsl();
if (!_ssl)
{
- BIO_free(bio);
+ BIO_free(_bio);
+ _bio = nullptr;
throw std::runtime_error("Failed to create SSL.");
}
- SSL_set_bio(_ssl, bio, bio);
+ SSL_set_bio(_ssl, _bio, _bio);
if (isClient)
{
@@ -240,6 +242,14 @@ private:
// Fallthrough...
default:
{
+ // Effectively an EAGAIN error at the BIO layer
+ if (BIO_should_retry(_bio))
+ {
+ LOG_TRC("Socket #" << getFD() << " BIO asks for retry - underlying EAGAIN? " <<
+ SSL_get_error(_ssl, rc));
+ return -1; // poll is used to detect real errors.
+ }
+
if (sslError == SSL_ERROR_SSL)
LOG_TRC("Socket #" << getFD() << " SSL error: SSL (" << sslError << ").");
else if (sslError == SSL_ERROR_SYSCALL)
@@ -289,6 +299,7 @@ private:
}
private:
+ BIO* _bio;
SSL* _ssl;
/// During handshake SSL might want to read
/// on write, or write on read.
More information about the Libreoffice-commits
mailing list