diff --git a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp index a93ad82e7c0..6bdd78b856a 100644 --- a/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp +++ b/src/cpp/rtps/transport/shared_mem/SharedMemManager.hpp @@ -783,10 +783,9 @@ class SharedMemManager : void regenerate_port() { - auto new_port = shared_mem_manager_->regenerate_port(global_port_, global_port_->open_mode()); - - auto new_listener = new_port->create_listener(); - + auto new_port = global_port_; + shared_mem_manager_->regenerate_port(new_port, new_port->open_mode()); + auto new_listener = std::make_shared(shared_mem_manager_, new_port); *this = std::move(*new_listener); } @@ -930,9 +929,7 @@ class SharedMemManager : void regenerate_port() { recover_blocked_processing(); - auto new_port = shared_mem_manager_->regenerate_port(global_port_, open_mode_); - - *this = std::move(*new_port); + shared_mem_manager_->regenerate_port(global_port_, open_mode_); } SharedMemManager* shared_mem_manager_; @@ -1016,11 +1013,11 @@ class SharedMemManager : private: - std::shared_ptr regenerate_port( - std::shared_ptr port, + void regenerate_port( + std::shared_ptr& port, SharedMemGlobal::Port::OpenMode open_mode) { - return std::make_shared(this, global_segment_.regenerate_port(port, open_mode), open_mode); + port = global_segment_.regenerate_port(port, open_mode); } /**