Making CcnxWrapper a singleton
diff --git a/ccnx/sync-app-socket.cc b/ccnx/sync-app-socket.cc
index b3ed61b..3da5402 100644
--- a/ccnx/sync-app-socket.cc
+++ b/ccnx/sync-app-socket.cc
@@ -29,7 +29,7 @@
{
SyncAppSocket::SyncAppSocket (const string &syncPrefix, NewDataCallback dataCallback, RemoveCallback rmCallback )
- : m_ccnxHandle (new CcnxWrapper())
+ : m_ccnxHandle (CcnxWrapper::Create ())
, m_newDataCallback(dataCallback)
, m_syncLogic (syncPrefix,
bind(&SyncAppSocket::passCallback, this, _1),
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index d0a6376..3e2ebc1 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -49,7 +49,6 @@
#ifdef _DEBUG_WRAPPER_
m_c = c;
#endif
- m_handle = ccn_create();
connectCcnd();
initKeyStore ();
createKeyLocator ();
@@ -59,7 +58,12 @@
void
CcnxWrapper::connectCcnd()
{
- ccn_disconnect (m_handle);
+ if (m_handle != 0) {
+ ccn_disconnect (m_handle);
+ ccn_destroy (&m_handle);
+ }
+
+ m_handle = ccn_create ();
_LOG_DEBUG("<<< connecting to ccnd");
if (ccn_connect(m_handle, NULL) < 0)
{
@@ -70,6 +74,7 @@
{
for (map<std::string, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
{
+ // clearInterestFilter(it->first);
setInterestFilter(it->first, it->second);
_LOG_DEBUG("<<< registering interest filter for: " << it->first);
}