diff --git a/Net/include/Poco/Net/SocketAcceptor.h b/Net/include/Poco/Net/SocketAcceptor.h index c9021ecd0..ad24703d1 100644 --- a/Net/include/Poco/Net/SocketAcceptor.h +++ b/Net/include/Poco/Net/SocketAcceptor.h @@ -105,12 +105,7 @@ public: void setReactor(SocketReactor& reactor) /// Sets the reactor for this acceptor. { - _pReactor = &reactor; - if (!_pReactor->hasEventHandler(_socket, Poco::Observer(*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(*this, &SocketAcceptor::onAccept)); + if (!_pReactor->hasEventHandler(_socket, Poco::Observer(*this, &SocketAcceptor::onAccept))) + { + _pReactor->addEventHandler(_socket, Poco::Observer(*this, &SocketAcceptor::onAccept)); + } } virtual void unregisterAcceptor()