Don't build Adjacency LSA when destroyed face belongs to INACTIVE node

refs: #2733

Change-Id: I2a53bce876486980b380e9d8226b410bc754b034
diff --git a/src/lsdb.hpp b/src/lsdb.hpp
index 7ab54e5..3cf74c6 100644
--- a/src/lsdb.hpp
+++ b/src/lsdb.hpp
@@ -172,10 +172,12 @@
   void
   exprireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
+PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   ndn::EventId
   scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
                            const seconds& expTime);
 
+private:
   void
   exprireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
 
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index 5d40002..2d58b19 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -296,13 +296,28 @@
       _LOG_DEBUG("Face to " << adjacent->getName() << " with face id: " << faceId << " destroyed");
 
       adjacent->setFaceId(0);
-      adjacent->setStatus(Adjacent::STATUS_INACTIVE);
 
-      // A new adjacency LSA cannot be built until the neighbor is marked INACTIVE and
-      // has met the HELLO retry threshold
-      adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
+      // Only trigger an Adjacency LSA build if this node is changing from ACTIVE to INACTIVE
+      // since this rebuild will effectively cancel the previous Adjacency LSA refresh event
+      // and schedule a new one further in the future.
+      //
+      // Continuously scheduling the refresh in the future will block the router from refreshing
+      // its Adjacency LSA. Since other routers' Name prefixes' expiration times are updated
+      // when this router refreshes its Adjacency LSA, the other routers' prefixes will expire
+      // and be removed from the RIB.
+      //
+      // This check is required to fix Bug #2733 for now. This check would be unnecessary
+      // to fix Bug #2733 when Issue #2732 is completed, but the check also helps with
+      // optimization so it can remain even when Issue #2732 is implemented.
+      if (adjacent->getStatus() == Adjacent::STATUS_ACTIVE) {
+        adjacent->setStatus(Adjacent::STATUS_INACTIVE);
 
-      m_nlsrLsdb.scheduleAdjLsaBuild();
+        // A new adjacency LSA cannot be built until the neighbor is marked INACTIVE and
+        // has met the HELLO retry threshold
+        adjacent->setInterestTimedOutNo(m_confParam.getInterestRetryNumber());
+
+        m_nlsrLsdb.scheduleAdjLsaBuild();
+      }
     }
   }
 }