mirror of https://github.com/Icinga/icinga2.git
parent
e4c5c9fe76
commit
8d5b270812
|
@ -34,6 +34,7 @@ struct SocketEventDescriptor
|
|||
{
|
||||
int Events;
|
||||
SocketEvents *EventInterface;
|
||||
Object *LifesupportObject;
|
||||
|
||||
SocketEventDescriptor(void)
|
||||
: Events(0)
|
||||
|
@ -125,7 +126,8 @@ void SocketEvents::ThreadProc(void)
|
|||
desc = it->second;
|
||||
|
||||
/* 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);
|
||||
|
@ -143,31 +145,32 @@ void SocketEvents::WakeUpThread(void)
|
|||
/**
|
||||
* Constructor for the SocketEvents class.
|
||||
*/
|
||||
SocketEvents::SocketEvents(const Socket::Ptr& socket)
|
||||
SocketEvents::SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject)
|
||||
: m_FD(socket->GetFD())
|
||||
{
|
||||
boost::call_once(l_SocketIOOnceFlag, &SocketEvents::InitializeThread);
|
||||
|
||||
Register();
|
||||
Register(lifesupportObject);
|
||||
}
|
||||
|
||||
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;
|
||||
desc.Events = 0;
|
||||
desc.EventInterface = this;
|
||||
desc.LifesupportObject = lifesupportObject;
|
||||
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -38,13 +38,12 @@ public:
|
|||
|
||||
virtual void OnEvent(int revents);
|
||||
|
||||
void Register(void);
|
||||
void Unregister(void);
|
||||
|
||||
void ChangeEvents(int events);
|
||||
|
||||
protected:
|
||||
SocketEvents(const Socket::Ptr& socket);
|
||||
SocketEvents(const Socket::Ptr& socket, Object *lifesupportObject);
|
||||
|
||||
private:
|
||||
SOCKET m_FD;
|
||||
|
@ -55,6 +54,8 @@ private:
|
|||
static void WakeUpThread(void);
|
||||
|
||||
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.
|
||||
*/
|
||||
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_CurrentAction(TlsActionNone), m_Retry(false)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue