fix memory leak in ccnx-tunnel
diff --git a/include/ccnx-closure.h b/include/ccnx-closure.h
index 66f79e8..f006d11 100644
--- a/include/ccnx-closure.h
+++ b/include/ccnx-closure.h
@@ -31,6 +31,9 @@
   virtual TimeoutCallbackReturnValue
   runTimeoutCallback(const Name &interest);
 
+  virtual Closure *
+  dup() const;
+
 protected:
   int m_retry;
   TimeoutCallback *m_timeoutCallback;
diff --git a/include/ccnx-tunnel.h b/include/ccnx-tunnel.h
index 0525458..b71d3c1 100644
--- a/include/ccnx-tunnel.h
+++ b/include/ccnx-tunnel.h
@@ -40,7 +40,7 @@
   publishContentObject(const Name &name, const Bytes &contentObject, int freshness);
 
   virtual int
-  sendInterest (const Name &interest, Closure *closure, const Selectors &selectors = Selectors());
+  sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors = Selectors());
 
 
   // prefix is topology-independent
@@ -95,6 +95,9 @@
   virtual TimeoutCallbackReturnValue
   runTimeoutCallback(const Name &interest) _OVERRIDE;
 
+  virtual Closure *
+  dup() const _OVERRIDE;
+
 private:
   CcnxTunnel *m_tunnel;
   Name m_originalInterest;
diff --git a/include/ccnx-wrapper.h b/include/ccnx-wrapper.h
index 12a5bc7..32999a3 100644
--- a/include/ccnx-wrapper.h
+++ b/include/ccnx-wrapper.h
@@ -37,7 +37,7 @@
   clearInterestFilter (const Name &prefix);
 
   virtual int
-  sendInterest (const Name &interest, Closure *closure, const Selectors &selector = Selectors());
+  sendInterest (const Name &interest, const Closure *closure, const Selectors &selector = Selectors());
 
   virtual int
   publishData (const Name &name, const unsigned char *buf, size_t len, int freshness);
diff --git a/src/ccnx-closure.cpp b/src/ccnx-closure.cpp
index a4c378c..528c721 100644
--- a/src/ccnx-closure.cpp
+++ b/src/ccnx-closure.cpp
@@ -44,4 +44,11 @@
   }
 }
 
+Closure *
+Closure::dup() const
+{
+  Closure *closure = new Closure(*this);
+  return closure;
+}
+
 } // Ccnx
diff --git a/src/ccnx-tunnel.cpp b/src/ccnx-tunnel.cpp
index 5e4d322..6a7dd29 100644
--- a/src/ccnx-tunnel.cpp
+++ b/src/ccnx-tunnel.cpp
@@ -8,7 +8,7 @@
                           : CcnxWrapper()
                           , m_localPrefix("/")
 {
-  //refreshLocalPrefix();
+  refreshLocalPrefix();
 }
 
 CcnxTunnel::~CcnxTunnel()
@@ -28,11 +28,12 @@
 }
 
 int
-CcnxTunnel::sendInterest (const Name &interest, Closure *closure, const Selectors &selectors)
+CcnxTunnel::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
 {
   Name tunneledInterest = queryRoutableName(interest);
   Closure *cp = new TunnelClosure(closure, this, interest);
   CcnxWrapper::sendInterest(tunneledInterest, cp, selectors);
+  delete cp;
 }
 
 void
@@ -55,7 +56,6 @@
 CcnxTunnel::publishContentObject(const Name &name, const Bytes &contentObject, int freshness)
 {
   Name tunneledName = m_localPrefix + name;
-  cout << "Outer name " << tunneledName;
   Bytes tunneledCo = createContentObject(tunneledName, head(contentObject), contentObject.size(), freshness);
   return putToCcnd(tunneledCo);
 }
@@ -129,6 +129,13 @@
 {
 }
 
+Closure *
+TunnelClosure::dup() const
+{
+  Closure *closure = new TunnelClosure(m_retry, *m_dataCallback, m_tunnel, m_originalInterest, *m_timeoutCallback);
+  return closure;
+}
+
 void
 TunnelClosure::runDataCallback(const Name &name, const Bytes &content)
 {
diff --git a/src/ccnx-wrapper.cpp b/src/ccnx-wrapper.cpp
index 981fdd4..0f4a8d5 100644
--- a/src/ccnx-wrapper.cpp
+++ b/src/ccnx-wrapper.cpp
@@ -257,6 +257,8 @@
   switch (kind)
     {
     case CCN_UPCALL_FINAL:  // effecitve in unit tests
+      delete cp;
+      cp = NULL;
       delete selfp;
       return CCN_UPCALL_RESULT_OK;
 
@@ -303,7 +305,7 @@
   return CCN_UPCALL_RESULT_OK;
 }
 
-int CcnxWrapper::sendInterest (const Name &interest, Closure *closure, const Selectors &selectors)
+int CcnxWrapper::sendInterest (const Name &interest, const Closure *closure, const Selectors &selectors)
 {
   UniqueRecLock(m_mutex);
   if (!m_running || !m_connected)
@@ -313,7 +315,8 @@
   ccn_charbuf *pname = namePtr->getBuf();
   ccn_closure *dataClosure = new ccn_closure;
 
-  dataClosure->data = (void *)closure;
+  Closure *myClosure = closure->dup();
+  dataClosure->data = (void *)myClosure;
 
   dataClosure->p = &incomingData;