SocketAcceptor::setReactor() is broken #2308

This commit is contained in:
Alex Fabijanic 2018-04-26 17:41:31 -05:00 committed by Alex Fabijanic
parent 1d08872981
commit 479bde1e46

View File

@ -105,12 +105,7 @@ public:
void setReactor(SocketReactor& reactor)
/// Sets the reactor for this acceptor.
{
_pReactor = &reactor;
if (!_pReactor->hasEventHandler(_socket, Poco::Observer<SocketAcceptor,
ReadableNotification>(*this, &SocketAcceptor::onAccept)))
{
registerAcceptor(reactor);
}
registerAcceptor(reactor);
}
virtual void registerAcceptor(SocketReactor& reactor)
@ -124,11 +119,12 @@ public:
/// implementation or directly register the accept handler with
/// the reactor.
{
if (_pReactor)
throw Poco::InvalidAccessException("Acceptor already registered.");
_pReactor = &reactor;
_pReactor->addEventHandler(_socket, Poco::Observer<SocketAcceptor, ReadableNotification>(*this, &SocketAcceptor::onAccept));
if (!_pReactor->hasEventHandler(_socket, Poco::Observer<SocketAcceptor,
ReadableNotification>(*this, &SocketAcceptor::onAccept)))
{
_pReactor->addEventHandler(_socket, Poco::Observer<SocketAcceptor, ReadableNotification>(*this, &SocketAcceptor::onAccept));
}
}
virtual void unregisterAcceptor()