Bug #2517
Updated by Alex Afanasyev almost 10 years ago
In some environments (specifically Android app), it may Given the following pseudocode: class NfdRunner { public: NfdRunner(const std::string& file) : m_nfd(configFile, m_keyChain) , m_nrd(config, m_keyChain) { m_nfd.initialize(); m_nrd.initialize(); } private: Nfd m_nfd; rib::Nrd m_nrd; }; NfdRunner* r = new NfdRunner("nfd.conf"); boost::asio::io_service* io = &getGlobalIoService(); boost::thread t = boost::thread([&] { boost::this_thread::sleep_for(time::seconds(2)); delete r; }); globalIoService().run(); There should not be necessary (at least needed for now) to start/stop NFD multiple times within the same process. any segfault produced as a result of this execution. This requires that Nrd/Nfd destructors properly NfdRunner destructor should destroy instances of nrd, nfd, which in turn should destroy everything internally and cancel everything that was posted on `io_service` The current way we do thing in main() is we stopping the global `io_service` first, after which we call the destructors. IO service. This effectively destructs everything, however there are dangling handlers posted that will be removed when the application After everything is terminated. This approach does not work when nfd needs to be started again within properly cancelled, the same process---whenever global `io_service` is started again, it will fire up a few handlers that point to deallocated memory. app should terminate.