diff --git a/experimental/distributed/src/communication.cpp b/experimental/distributed/src/communication.cpp index feb9b2886..b858e82ba 100644 --- a/experimental/distributed/src/communication.cpp +++ b/experimental/distributed/src/communication.cpp @@ -33,7 +33,6 @@ std::pair<EventStream*, std::shared_ptr<Channel>> Reactor::Open(const std::strin std::unique_lock<std::mutex> lock(*mutex_); // TODO: Improve the check that the channel name does not exist in the // system. - assert(connectors_.count(connector_name) == 0); if (connectors_.count(connector_name) != 0) { throw std::runtime_error("Connector with name " + connector_name + "already exists"); diff --git a/experimental/distributed/src/communication.hpp b/experimental/distributed/src/communication.hpp index 059de9f97..b148f950c 100644 --- a/experimental/distributed/src/communication.hpp +++ b/experimental/distributed/src/communication.hpp @@ -546,9 +546,8 @@ class Network { void StopServer() { if (server_ != nullptr) { server_->Shutdown(); - server_ = nullptr; + thread_.join(); } - thread_.join(); } private: diff --git a/experimental/distributed/tests/connector_unit.cpp b/experimental/distributed/tests/connector_unit.cpp index 18e81e2fa..120fe451a 100644 --- a/experimental/distributed/tests/connector_unit.cpp +++ b/experimental/distributed/tests/connector_unit.cpp @@ -10,6 +10,21 @@ #include "communication.hpp" +TEST(SystemTest, ReturnWithoutThrowing) { + struct Master : public Reactor { + Master(System *system, std::string name) : Reactor(system, name) {} + virtual void Run() { + CloseConnector("main"); + } + }; + + System system; + ASSERT_NO_THROW(system.StartServices()); + ASSERT_NO_THROW(system.Spawn<Master>("master")); + ASSERT_NO_THROW(system.AwaitShutdown()); +} + + TEST(ChannelCreationTest, ThrowOnReusingChannelName) { struct Master : public Reactor { Master(System *system, std::string name) : Reactor(system, name) {}