node+transport: Fixing bug that prevented reconnection to the forwarder after being disconnected for some reason
tools/ndnputcatchunks shows an example how to design a daemon
application that is resilient to the local daemon shutdowns/restarts.
Note that when local forwarder disconnects, all pending interests and
registered prefixes will get flushed.
Change-Id: I2933e2b5d6fd8420de4f055e53c748dbd00cabe9
diff --git a/src/node.cpp b/src/node.cpp
index 6641bbc..26a3b07 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -274,12 +274,20 @@
}
ioService_->run();
+ ioService_->reset(); // so it is possible to run processEvents again (if necessary)
}
catch(Node::ProcessEventsTimeout &)
{
// break
ioService_->reset();
}
+ catch(const std::exception &)
+ {
+ ioService_->reset();
+ pendingInterestTable_.clear();
+ registeredPrefixTable_.clear();
+ throw;
+ }
}
void
@@ -364,13 +372,13 @@
void
Node::shutdown()
{
+ pendingInterestTable_.clear();
+ registeredPrefixTable_.clear();
+
transport_->close();
pitTimeoutCheckTimer_->cancel();
processEventsTimeoutTimer_->cancel();
pitTimeoutCheckTimerActive_ = false;
-
- // This will ensure that io_service::work will stop
- ioServiceWork_.reset();
}
Node::PendingInterestTable::iterator