Fix crash in TlsStream::IsEof

refs #6862
This commit is contained in:
Gunnar Beutner 2014-09-10 08:51:25 +02:00
parent fbce8e430a
commit dc4fe38d8f
2 changed files with 7 additions and 3 deletions

View File

@ -36,7 +36,7 @@ bool I2_EXPORT TlsStream::m_SSLIndexInitialized = false;
* @param sslContext The SSL context for the client.
*/
TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const shared_ptr<SSL_CTX>& sslContext)
: m_Socket(socket), m_Role(role)
: m_Eof(false), m_Socket(socket), m_Role(role)
{
std::ostringstream msgbuf;
char errbuf[120];
@ -248,6 +248,10 @@ void TlsStream::Write(const void *buffer, size_t count)
*/
void TlsStream::Close(void)
{
boost::mutex::scoped_lock alock(m_IOActionLock);
m_Eof = true;
for (int i = 0; i < 5; i++) {
int rc, err;
@ -286,5 +290,5 @@ close_socket:
bool TlsStream::IsEof(void) const
{
return (BIO_eof(m_BIO) == 1);
return m_Eof;
}

View File

@ -54,9 +54,9 @@ public:
private:
shared_ptr<SSL> m_SSL;
bool m_Eof;
mutable boost::mutex m_SSLLock;
mutable boost::mutex m_IOActionLock;
BIO *m_BIO;
Socket::Ptr m_Socket;
ConnectionRole m_Role;