mgmt: InternalFace processes Interest asynchronously

This avoids forwarding's incoming Data pipeline to be called
within incoming Interest pipeline - this property holds for
other faces, and is expected by forwarding.

refs #1419

Change-Id: I3eb1ca84830d5d8aefe0ae67a562acdd835ca5ca
diff --git a/daemon/mgmt/internal-face.cpp b/daemon/mgmt/internal-face.cpp
index 5552d02..81bd2de 100644
--- a/daemon/mgmt/internal-face.cpp
+++ b/daemon/mgmt/internal-face.cpp
@@ -5,6 +5,7 @@
  */
 
 #include "internal-face.hpp"
+#include "core/global-io.hpp"
 
 namespace nfd {
 
@@ -20,6 +21,15 @@
 {
   onSendInterest(interest);
 
+  // Invoke .processInterest a bit later,
+  // to avoid potential problems in forwarding pipelines.
+  getGlobalIoService().post(bind(&InternalFace::processInterest,
+                                 this, boost::cref(interest)));
+}
+
+void
+InternalFace::processInterest(const Interest& interest)
+{
   if (m_interestFilters.size() == 0)
     {
       NFD_LOG_DEBUG("no Interest filters to match against");
diff --git a/daemon/mgmt/internal-face.hpp b/daemon/mgmt/internal-face.hpp
index 3ce32e3..3f061fb 100644
--- a/daemon/mgmt/internal-face.hpp
+++ b/daemon/mgmt/internal-face.hpp
@@ -20,9 +20,14 @@
   /**
    * \brief InternalFace-related error
    */
-  struct Error : public Face::Error
+  class Error : public Face::Error
   {
-    Error(const std::string& what) : Face::Error(what) {}
+  public:
+    explicit
+    Error(const std::string& what)
+      : Face::Error(what)
+    {
+    }
   };
 
   InternalFace();
@@ -54,7 +59,10 @@
   put(const Data& data);
 
 private:
+  void
+  processInterest(const Interest& interest);
 
+private:
   std::map<Name, OnInterest> m_interestFilters;
   CommandValidator m_validator;
 };