]> granicus.if.org Git - icinga2/commitdiff
Fix spurious SSL errors
authorGunnar Beutner <gunnar@beutner.name>
Fri, 5 Sep 2014 06:19:47 +0000 (08:19 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 5 Sep 2014 06:19:47 +0000 (08:19 +0200)
fixes #6981

lib/base/tlsstream.cpp
lib/base/tlsstream.hpp

index cc1b304587b1cb6d202b172dd1dd36200bc5a513..17585bf6aad6ab00af50ee7416cc71766986dcb5 100644 (file)
@@ -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;
 
index 1c8174564cceaa605980bc8af723a3c63b0cb1d9..a6a55e68d58b5d230bf1ec9917b47e811c13536a 100644 (file)
@@ -55,6 +55,7 @@ public:
 private:
        shared_ptr<SSL> m_SSL;
        mutable boost::mutex m_SSLLock;
+       mutable boost::mutex m_IOActionLock;
        BIO *m_BIO;
 
        Socket::Ptr m_Socket;