Implemented set to monitor pending interests in manager.

Change-Id: I4a11db79053e69a19ceba0e0501b93911131d1d7
diff --git a/src/torrent-manager.cpp b/src/torrent-manager.cpp
index 8e525e0..179893e 100644
--- a/src/torrent-manager.cpp
+++ b/src/torrent-manager.cpp
@@ -381,6 +381,7 @@
 
   auto dataReceived = [path, onSuccess, onFailed, this]
                                             (const Interest& interest, const Data& data) {
+      m_pendingInterests.erase(interest.getName());
       // Stats Table update here...
       m_stats_table_iter->incrementReceivedData();
       m_retries = 0;
@@ -402,6 +403,9 @@
       if (nextSegmentPtr != nullptr) {
         this->downloadTorrentFileSegment(*nextSegmentPtr, path, onSuccess, onFailed);
       }
+      if (!m_seedFlag && m_pendingInterests.empty()) {
+        shutdown();
+      }
   };
 
   auto dataFailed = [path, name, onSuccess, onFailed, this]
@@ -418,7 +422,8 @@
     }
     this->downloadTorrentFileSegment(name, path, onSuccess, onFailed);
   };
-  LOG_TRACE << "Sending: " << *interest << std::endl;
+  m_pendingInterests.insert(interest->getName());
+  LOG_DEBUG << "Sending: " << *interest << std::endl;
   m_face->expressInterest(*interest, dataReceived, dataFailed);
 }
 
@@ -471,6 +476,7 @@
 
   auto dataReceived = [onSuccess, onFailed, this]
                                           (const Interest& interest, const Data& data) {
+    m_pendingInterests.erase(interest.getName());
     // Write data to disk...
     if(writeData(data)) {
       seed(data);
@@ -479,6 +485,9 @@
     m_stats_table_iter->incrementReceivedData();
     m_retries = 0;
     onSuccess(data.getName());
+    if (!m_seedFlag && m_pendingInterests.empty()) {
+      shutdown();
+    }
   };
   auto dataFailed = [onFailed, this]
                              (const Interest& interest) {
@@ -491,7 +500,8 @@
     }
     onFailed(interest.getName(), "Unknown failure");
   };
-  LOG_TRACE << "Sending: " <<  *interest << std::endl;
+  m_pendingInterests.insert(interest->getName());
+  LOG_DEBUG << "Sending: " <<  *interest << std::endl;
   m_face->expressInterest(*interest, dataReceived, dataFailed);
 }
 
@@ -605,6 +615,7 @@
 
   auto dataReceived = [packetNames, path, onSuccess, onFailed, this]
                                           (const Interest& interest, const Data& data) {
+    m_pendingInterests.erase(interest.getName());
     // Stats Table update here...
     m_stats_table_iter->incrementReceivedData();
     m_retries = 0;
@@ -628,6 +639,9 @@
     else {
       onSuccess(*packetNames);
     }
+    if (!m_seedFlag && m_pendingInterests.empty()) {
+      shutdown();
+    }
   };
 
   auto dataFailed = [packetNames, path, manifestName, onFailed, this]
@@ -640,7 +654,8 @@
     }
     onFailed(interest.getName(), "Unknown failure");
   };
-  LOG_TRACE << "Sending: " <<  *interest << std::endl;
+  m_pendingInterests.insert(interest->getName());
+  LOG_DEBUG << "Sending: " <<  *interest << std::endl;
   m_face->expressInterest(*interest, dataReceived, dataFailed);
 }
 
@@ -648,7 +663,7 @@
 TorrentManager::onInterestReceived(const InterestFilter& filter, const Interest& interest)
 {
   // handle if it is a torrent-file
-  LOG_TRACE << "Interest Recevied: " << interest << std::endl;
+  LOG_DEBUG << "Interest Recevied: " << interest << std::endl;
   const auto& interestName = interest.getName();
   std::shared_ptr<Data> data = nullptr;
   auto cmp = [&interestName](const Data& t){return t.getFullName() == interestName;};
@@ -712,7 +727,7 @@
   LOG_ERROR << "ERROR: Failed to register prefix \""
             << prefix << "\" in local hub's daemon (" << reason << ")"
             << std::endl;
-  m_face->shutdown();
+  shutdown();
 }
 
 shared_ptr<Interest>