]> granicus.if.org Git - icinga2/commitdiff
Avoid unnecessary Poll() calls
authorGunnar Beutner <gunnar@beutner.name>
Fri, 17 Oct 2014 22:29:39 +0000 (00:29 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 17 Oct 2014 22:29:39 +0000 (00:29 +0200)
lib/base/tlsstream.cpp

index a7664821bb8d5da2ded98bfb30fe1548a7400160..a2d81217142fb257bcbf77cc0527112cbc446a2f 100644 (file)
@@ -161,7 +161,14 @@ size_t TlsStream::Read(void *buffer, size_t count)
        std::ostringstream msgbuf;
        char errbuf[120];
 
-       if (SSL_want_read(m_SSL.get()))
+       bool want_read;
+
+       {
+               boost::mutex::scoped_lock lock(m_SSLLock);
+               want_read = !SSL_pending(m_SSL.get()) || SSL_want_read(m_SSL.get());
+       }
+
+       if (want_read)
                m_Socket->Poll(true, false);
 
        boost::mutex::scoped_lock alock(m_IOActionLock);
@@ -216,10 +223,7 @@ void TlsStream::Write(const void *buffer, size_t count)
        std::ostringstream msgbuf;
        char errbuf[120];
 
-       bool want_write;
-
-       if (SSL_want_write(m_SSL.get()))
-               m_Socket->Poll(false, true);
+       m_Socket->Poll(false, true);
 
        boost::mutex::scoped_lock alock(m_IOActionLock);