rib: Request Face create/destroy notification as early as possible

This commit does not completely solve the problem, as depending on
ContentStore size and amount of updates, some notification still can be
missed.  However, this commit reduces chances for this to happen.

Change-Id: I5456667c1fba1031146b379195de852f1561fd5d
Refs: #1742
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index 8b7010a..d04737c 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -26,6 +26,7 @@
 #include "rib-manager.hpp"
 #include "core/global-io.hpp"
 #include "core/logger.hpp"
+#include "core/scheduler.hpp"
 
 namespace nfd {
 namespace rib {
@@ -532,13 +533,21 @@
   NFD_LOG_TRACE("onNotification: " << notification);
   if (notification.getKind() == ndn::nfd::FACE_EVENT_DESTROYED) //face destroyed
     {
-      m_managedRib.erase(notification.getFaceId());
-
-      sendUpdatesToFibAfterFaceDestroyEvent();
+      scheduler::schedule(time::seconds(0),
+                          bind(&RibManager::processErasureAfterNotification, this,
+                               notification.getFaceId()));
     }
 }
 
 void
+RibManager::processErasureAfterNotification(uint64_t faceId)
+{
+  m_managedRib.erase(faceId);
+
+  sendUpdatesToFibAfterFaceDestroyEvent();
+}
+
+void
 RibManager::sendUpdatesToFib(const shared_ptr<const Interest>& request,
                              const ControlParameters& parameters)
 {
diff --git a/rib/rib-manager.hpp b/rib/rib-manager.hpp
index 6f90a80..f664528 100644
--- a/rib/rib-manager.hpp
+++ b/rib/rib-manager.hpp
@@ -177,6 +177,9 @@
   onNotification(const FaceEventNotification& notification);
 
   void
+  processErasureAfterNotification(uint64_t faceId);
+
+  void
   sendUpdatesToFib(const shared_ptr<const Interest>& request,
                    const ControlParameters& parameters);