mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
parent
4bb9beda19
commit
5a74f69819
@ -36,7 +36,7 @@ class I2_BASE_API FIFO : public Stream
|
|||||||
public:
|
public:
|
||||||
DECLARE_PTR_TYPEDEFS(FIFO);
|
DECLARE_PTR_TYPEDEFS(FIFO);
|
||||||
|
|
||||||
static const size_t BlockSize = 16 * 1024;
|
static const size_t BlockSize = 512;
|
||||||
|
|
||||||
FIFO(void);
|
FIFO(void);
|
||||||
~FIFO(void);
|
~FIFO(void);
|
||||||
|
@ -27,6 +27,8 @@ NetworkStream::NetworkStream(const Socket::Ptr& socket)
|
|||||||
|
|
||||||
void NetworkStream::Close(void)
|
void NetworkStream::Close(void)
|
||||||
{
|
{
|
||||||
|
Stream::Close();
|
||||||
|
|
||||||
m_Socket->Close();
|
m_Socket->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +55,8 @@ void StdioStream::Write(const void *buffer, size_t size)
|
|||||||
|
|
||||||
void StdioStream::Close(void)
|
void StdioStream::Close(void)
|
||||||
{
|
{
|
||||||
|
Stream::Close();
|
||||||
|
|
||||||
if (m_OwnsStream) {
|
if (m_OwnsStream) {
|
||||||
delete m_InnerStream;
|
delete m_InnerStream;
|
||||||
m_OwnsStream = false;
|
m_OwnsStream = false;
|
||||||
|
@ -76,6 +76,11 @@ bool Stream::WaitForData(int timeout)
|
|||||||
return IsDataAvailable() || IsEof();
|
return IsDataAvailable() || IsEof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Stream::Close(void)
|
||||||
|
{
|
||||||
|
OnDataAvailable.disconnect_all_slots();
|
||||||
|
}
|
||||||
|
|
||||||
StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool may_wait)
|
StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool may_wait)
|
||||||
{
|
{
|
||||||
if (context.Eof)
|
if (context.Eof)
|
||||||
|
@ -113,7 +113,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Closes the stream and releases resources.
|
* Closes the stream and releases resources.
|
||||||
*/
|
*/
|
||||||
virtual void Close(void) = 0;
|
virtual void Close(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether we've reached the end-of-file condition.
|
* Checks whether we've reached the end-of-file condition.
|
||||||
|
@ -85,7 +85,7 @@ TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, Connecti
|
|||||||
|
|
||||||
TlsStream::~TlsStream(void)
|
TlsStream::~TlsStream(void)
|
||||||
{
|
{
|
||||||
SocketEvents::Unregister();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TlsStream::ValidateCertificate(int preverify_ok, X509_STORE_CTX *ctx)
|
int TlsStream::ValidateCertificate(int preverify_ok, X509_STORE_CTX *ctx)
|
||||||
@ -216,33 +216,31 @@ void TlsStream::OnEvent(int revents)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case SSL_ERROR_ZERO_RETURN:
|
case SSL_ERROR_ZERO_RETURN:
|
||||||
SocketEvents::Unregister();
|
lock.unlock();
|
||||||
|
|
||||||
m_SSL.reset();
|
if (IsHandlingEvents())
|
||||||
m_Socket->Close();
|
SignalDataAvailable();
|
||||||
m_Socket.reset();
|
|
||||||
|
|
||||||
m_Eof = true;
|
Close();
|
||||||
|
|
||||||
m_CV.notify_all();
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SocketEvents::Unregister();
|
|
||||||
|
|
||||||
m_SSL.reset();
|
|
||||||
m_Socket->Close();
|
|
||||||
m_Socket.reset();
|
|
||||||
|
|
||||||
m_Eof = true;
|
|
||||||
|
|
||||||
m_ErrorCode = ERR_peek_error();
|
m_ErrorCode = ERR_peek_error();
|
||||||
m_ErrorOccurred = true;
|
m_ErrorOccurred = true;
|
||||||
|
|
||||||
|
if (m_ErrorCode != 0) {
|
||||||
Log(LogWarning, "TlsStream")
|
Log(LogWarning, "TlsStream")
|
||||||
<< "OpenSSL error: " << ERR_error_string(m_ErrorCode, NULL);
|
<< "OpenSSL error: " << ERR_error_string(m_ErrorCode, NULL);
|
||||||
|
} else {
|
||||||
|
Log(LogWarning, "TlsStream", "TLS stream was disconnected.");
|
||||||
|
}
|
||||||
|
|
||||||
m_CV.notify_all();
|
lock.unlock();
|
||||||
|
|
||||||
|
if (IsHandlingEvents())
|
||||||
|
SignalDataAvailable();
|
||||||
|
|
||||||
|
Close();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -318,6 +316,8 @@ void TlsStream::Shutdown(void)
|
|||||||
*/
|
*/
|
||||||
void TlsStream::Close(void)
|
void TlsStream::Close(void)
|
||||||
{
|
{
|
||||||
|
Stream::Close();
|
||||||
|
|
||||||
SocketEvents::Unregister();
|
SocketEvents::Unregister();
|
||||||
|
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
@ -332,6 +332,8 @@ void TlsStream::Close(void)
|
|||||||
|
|
||||||
m_Socket->Close();
|
m_Socket->Close();
|
||||||
m_Socket.reset();
|
m_Socket.reset();
|
||||||
|
|
||||||
|
m_CV.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TlsStream::IsEof(void) const
|
bool TlsStream::IsEof(void) const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user