From 9133c01f008cdb729a4d8081ff7d9fac8452a319 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 5 Sep 2014 08:19:47 +0200 Subject: [PATCH] Fix spurious SSL errors fixes #6981 --- lib/base/tlsstream.cpp | 10 ++++++++++ lib/base/tlsstream.hpp | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp index cc1b30458..17585bf6a 100644 --- a/lib/base/tlsstream.cpp +++ b/lib/base/tlsstream.cpp @@ -98,6 +98,8 @@ void TlsStream::Handshake(void) std::ostringstream msgbuf; char errbuf[120]; + boost::mutex::scoped_lock alock(m_IOActionLock); + for (;;) { int rc, err; @@ -145,6 +147,10 @@ size_t TlsStream::Read(void *buffer, size_t count) std::ostringstream msgbuf; char errbuf[120]; + m_Socket->Poll(true, false); + + boost::mutex::scoped_lock alock(m_IOActionLock); + while (left > 0) { int rc, err; @@ -193,6 +199,10 @@ void TlsStream::Write(const void *buffer, size_t count) std::ostringstream msgbuf; char errbuf[120]; + m_Socket->Poll(false, true); + + boost::mutex::scoped_lock alock(m_IOActionLock); + while (left > 0) { int rc, err; diff --git a/lib/base/tlsstream.hpp b/lib/base/tlsstream.hpp index 1c8174564..a6a55e68d 100644 --- a/lib/base/tlsstream.hpp +++ b/lib/base/tlsstream.hpp @@ -55,6 +55,7 @@ public: private: shared_ptr m_SSL; mutable boost::mutex m_SSLLock; + mutable boost::mutex m_IOActionLock; BIO *m_BIO; Socket::Ptr m_Socket;