From 479bde1e46575bfbe27e835ac756e7b5f4f144de Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Thu, 26 Apr 2018 17:41:31 -0500 Subject: [PATCH] SocketAcceptor::setReactor() is broken #2308 --- Net/include/Poco/Net/SocketAcceptor.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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()