diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-08-02 13:57:54 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-08-02 13:57:54 (GMT) |
commit | 8c60e86c8fc2cf60825c0ffbd882693dccf0b33c (patch) | |
tree | 9c7cfd05f4a55fefc31cc559a362504fdbd7d4de /Swiften/Network | |
parent | 475cec615cda74aa34d9519239e2f627256ef71d (diff) | |
download | swift-8c60e86c8fc2cf60825c0ffbd882693dccf0b33c.zip swift-8c60e86c8fc2cf60825c0ffbd882693dccf0b33c.tar.bz2 |
Slimber: Handle conflicts/restarts.
Diffstat (limited to 'Swiften/Network')
-rw-r--r-- | Swiften/Network/BoostConnectionServer.cpp | 10 | ||||
-rw-r--r-- | Swiften/Network/BoostConnectionServer.h | 1 | ||||
-rw-r--r-- | Swiften/Network/ConnectionServer.h | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/Swiften/Network/BoostConnectionServer.cpp b/Swiften/Network/BoostConnectionServer.cpp index 596761a..97c1316 100644 --- a/Swiften/Network/BoostConnectionServer.cpp +++ b/Swiften/Network/BoostConnectionServer.cpp @@ -21,10 +21,10 @@ void BoostConnectionServer::start() { } catch (const boost::system::system_error& e) { if (e.code() == boost::asio::error::address_in_use) { - onStopped(Conflict); + MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), Conflict), shared_from_this()); } else { - onStopped(UnknownError); + MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), UnknownError), shared_from_this()); } } } @@ -39,7 +39,11 @@ void BoostConnectionServer::stop(boost::optional<Error> e) { acceptor_->close(); acceptor_ = NULL; } - onStopped(e); + MainEventLoop::postEvent(boost::bind(boost::ref(onStopped), e), shared_from_this()); +} + +void BoostConnectionServer::cancelAllEvents() { + MainEventLoop::removeEventsFromOwner(shared_from_this()); } void BoostConnectionServer::acceptNextConnection() { diff --git a/Swiften/Network/BoostConnectionServer.h b/Swiften/Network/BoostConnectionServer.h index d8e5eb4..13d87a5 100644 --- a/Swiften/Network/BoostConnectionServer.h +++ b/Swiften/Network/BoostConnectionServer.h @@ -20,6 +20,7 @@ namespace Swift { void start(); void stop(); + virtual void cancelAllEvents(); boost::signal<void (boost::optional<Error>)> onStopped; diff --git a/Swiften/Network/ConnectionServer.h b/Swiften/Network/ConnectionServer.h index 539367d..9300092 100644 --- a/Swiften/Network/ConnectionServer.h +++ b/Swiften/Network/ConnectionServer.h @@ -10,6 +10,8 @@ namespace Swift { public: virtual ~ConnectionServer(); + virtual void cancelAllEvents() = 0; + boost::signal<void (boost::shared_ptr<Connection>)> onNewConnection; }; } |