rib: Cancel expiration on unregistration

refs: #1902

Change-Id: I85a75370ecc3677c8a9ebf3a48f3c0857598da2d
diff --git a/rib/rib-manager.cpp b/rib/rib-manager.cpp
index aa859e2..59e6230 100644
--- a/rib/rib-manager.cpp
+++ b/rib/rib-manager.cpp
@@ -286,10 +286,11 @@
 
       // Schedule a new event, the old one will be cancelled during rib insertion.
       EventId eventId;
-      NFD_LOG_TRACE("scheduling unregistration at: " << faceEntry.expires);
       eventId = scheduler::schedule(parameters.getExpirationPeriod(),
-                                    bind(&RibManager::unregisterEntry,
+                                    bind(&RibManager::expireEntry,
                                     this, shared_ptr<Interest>(), parameters));
+      NFD_LOG_TRACE("Scheduled unregistration at: " << faceEntry.expires <<
+                    " with EventId: " << eventId);
 
       //set the  NewEventId of this entry
       faceEntry.setExpirationEvent(eventId);
@@ -307,6 +308,19 @@
 }
 
 void
+RibManager::expireEntry(const shared_ptr<const Interest>& request, ControlParameters& params)
+{
+  FaceEntry face;
+  face.faceId = params.getFaceId();
+  face.origin = params.getOrigin();
+  face.cost = params.getCost();
+  face.flags = params.getFlags();
+
+  NFD_LOG_DEBUG(face << " for " << params.getName() << " has expired");
+  unregisterEntry(request, params);
+}
+
+void
 RibManager::unregisterEntry(const shared_ptr<const Interest>& request,
                             ControlParameters& params)
 {