mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
parent
e4c5c9fe76
commit
8d5b270812
@ -34,6 +34,7 @@ struct SocketEventDescriptor
|
|||||||
{
|
{
|
||||||
int Events;
|
int Events;
|
||||||
SocketEvents *EventInterface;
|
SocketEvents *EventInterface;
|
||||||
|
Object *LifesupportObject;
|
||||||
|
|
||||||
SocketEventDescriptor(void)
|
SocketEventDescriptor(void)
|
||||||
: Events(0)
|
: Events(0)
|
||||||
@ -125,7 +126,8 @@ void SocketEvents::ThreadProc(void)
|
|||||||
desc = it->second;
|
desc = it->second;
|
||||||
|
|
||||||
/* We must hold a ref-counted reference to the event object to keep it alive. */
|
/* We must hold a ref-counted reference to the event object to keep it alive. */
|
||||||
ltref = dynamic_cast<Object *>(desc.EventInterface);
|
ltref = desc.LifesupportObject;
|
||||||
|
VERIFY(ltref);
|
||||||
}
|
}
|
||||||
|
|
||||||
desc.EventInterface->OnEvent(pfds[i].revents);
|
desc.EventInterface->OnEvent(pfds[i].revents);
|
||||||
@ -143,31 +145,32 @@ void SocketEvents::WakeUpThread(void)
|
|||||||
/**
|
/**
|
||||||
* Constructor for the SocketEvents class.
|
* Constructor for the SocketEvents class.
|
||||||
*/
|
*/
|
||||||
SocketEvents::SocketEvents(const Socket::Ptr& socket)
|
SocketEvents::SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject)
|
||||||
: m_FD(socket->GetFD())
|
: m_FD(socket->GetFD())
|
||||||
{
|
{
|
||||||
boost::call_once(l_SocketIOOnceFlag, &SocketEvents::InitializeThread);
|
boost::call_once(l_SocketIOOnceFlag, &SocketEvents::InitializeThread);
|
||||||
|
|
||||||
Register();
|
Register(lifesupportObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketEvents::~SocketEvents(void)
|
SocketEvents::~SocketEvents(void)
|
||||||
{
|
{
|
||||||
ASSERT(m_FD == INVALID_SOCKET);
|
VERIFY(m_FD == INVALID_SOCKET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SocketEvents::Register(void)
|
void SocketEvents::Register(Object *lifesupportObject)
|
||||||
{
|
{
|
||||||
ASSERT(m_FD != INVALID_SOCKET);
|
VERIFY(m_FD != INVALID_SOCKET);
|
||||||
|
|
||||||
SocketEventDescriptor desc;
|
SocketEventDescriptor desc;
|
||||||
desc.Events = 0;
|
desc.Events = 0;
|
||||||
desc.EventInterface = this;
|
desc.EventInterface = this;
|
||||||
|
desc.LifesupportObject = lifesupportObject;
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
boost::mutex::scoped_lock lock(l_SocketIOMutex);
|
||||||
|
|
||||||
ASSERT(l_SocketIOSockets.find(m_FD) == l_SocketIOSockets.end());
|
VERIFY(l_SocketIOSockets.find(m_FD) == l_SocketIOSockets.end());
|
||||||
|
|
||||||
l_SocketIOSockets[m_FD] = desc;
|
l_SocketIOSockets[m_FD] = desc;
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,12 @@ public:
|
|||||||
|
|
||||||
virtual void OnEvent(int revents);
|
virtual void OnEvent(int revents);
|
||||||
|
|
||||||
void Register(void);
|
|
||||||
void Unregister(void);
|
void Unregister(void);
|
||||||
|
|
||||||
void ChangeEvents(int events);
|
void ChangeEvents(int events);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SocketEvents(const Socket::Ptr& socket);
|
SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SOCKET m_FD;
|
SOCKET m_FD;
|
||||||
@ -55,6 +54,8 @@ private:
|
|||||||
static void WakeUpThread(void);
|
static void WakeUpThread(void);
|
||||||
|
|
||||||
int GetPollEvents(void) const;
|
int GetPollEvents(void) const;
|
||||||
|
|
||||||
|
void Register(Object *lifesupportObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ bool I2_EXPORT TlsStream::m_SSLIndexInitialized = false;
|
|||||||
* @param sslContext The SSL context for the client.
|
* @param sslContext The SSL context for the client.
|
||||||
*/
|
*/
|
||||||
TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext)
|
TlsStream::TlsStream(const Socket::Ptr& socket, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext)
|
||||||
: SocketEvents(socket), m_Eof(false), m_HandshakeOK(false), m_VerifyOK(true), m_CloseOK(false), m_ErrorCode(0),
|
: SocketEvents(socket, this), m_Eof(false), m_HandshakeOK(false), m_VerifyOK(true), m_CloseOK(false), m_ErrorCode(0),
|
||||||
m_ErrorOccurred(false), m_Socket(socket), m_Role(role), m_SendQ(new FIFO()), m_RecvQ(new FIFO()),
|
m_ErrorOccurred(false), m_Socket(socket), m_Role(role), m_SendQ(new FIFO()), m_RecvQ(new FIFO()),
|
||||||
m_CurrentAction(TlsActionNone), m_Retry(false)
|
m_CurrentAction(TlsActionNone), m_Retry(false)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user