
Here's the relevant code:
boost::asio::io_service mIOService; boost::asio::deadline_timer mTimer(mIOService, boost::posix_time::seconds(3))
inline void TimerHandler(const boost::system::error_code& err) { cout << err; if (err && err != boost::asio::error::operation_aborted) { cout << endl << "Watchdog elapsed" << endl; } }
void Start() { mTimer.async_wait(TimerHandler); mIOService.run(); }
// Cancels and restarts the watchdog timer - prevents a timeout void Restart() { mTimer.cancel(); mTimer.async_wait(TimerHandler); mIOService.reset(); mIOService.run(); }
The flow is not clear. Your io_service goes out of work and run() exits, then you call Restart()? All this happens on the same thread? If so, try to move reset() to the beginning of the function.