Bug #2517
Updated by Alex Afanasyev almost 10 years ago
In some environments (specifically Android app), it may be necessary (at least needed for now) to start/stop NFD multiple times within the same process. This requires that Nrd/Nfd destructors properly cancel everything that was posted on `io_service` **without requiring to stop `io_service`**.
The current way we do thing in main() is we stopping the global `io_service` first, after which we call the destructors. This effectively destructs everything, however there are dangling handlers posted that will be removed when the application is terminated. This approach does not work when nfd needs to be started again within the same process---whenever global `io_service` is started again, it will fire up a few handlers that point to deallocated memory.