src: destruct logic and socket properly

Change-Id: Iedd14dcd7cb9567d549513e6fee3a18dd45f1d83
diff --git a/common.hpp b/common.hpp
index 1e0d02f..2ddc3d9 100644
--- a/common.hpp
+++ b/common.hpp
@@ -64,17 +64,17 @@
 using boost::noncopyable;
 using boost::scoped_ptr;
 
-using ndn::shared_ptr;
-using ndn::weak_ptr;
-using ndn::enable_shared_from_this;
-using ndn::make_shared;
-using ndn::static_pointer_cast;
-using ndn::dynamic_pointer_cast;
-using ndn::const_pointer_cast;
-using ndn::function;
-using ndn::bind;
-using ndn::ref;
-using ndn::cref;
+using std::shared_ptr;
+using std::weak_ptr;
+using std::enable_shared_from_this;
+using std::make_shared;
+using std::static_pointer_cast;
+using std::dynamic_pointer_cast;
+using std::const_pointer_cast;
+using std::function;
+using std::bind;
+using std::ref;
+using std::cref;
 
 using ndn::Interest;
 using ndn::Data;
diff --git a/src/logic.cpp b/src/logic.cpp
index 48d6cfb..25f2abb 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -116,8 +116,9 @@
 
 Logic::~Logic()
 {
-  m_face.unsetInterestFilter(m_syncRegisteredPrefixId);
   m_scheduler.cancelAllEvents();
+  m_interestTable.clear();
+  m_face.shutdown();
 }
 
 void
diff --git a/src/logic.hpp b/src/logic.hpp
index b7bfbdf..d4a811f 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -101,6 +101,7 @@
   /**
    * @brief Constructor
    *
+   * @param face The face used to communication, will be shutdown in destructor
    * @param syncPrefix The prefix of the sync group
    * @param defaultUserPrefix The prefix of the first user added to this session
    * @param onUpdate The callback function to handle state updates
diff --git a/src/socket.hpp b/src/socket.hpp
index 450dfeb..d213018 100644
--- a/src/socket.hpp
+++ b/src/socket.hpp
@@ -192,7 +192,6 @@
 
   Name m_userPrefix;
   ndn::Face& m_face;
-
   Logic m_logic;
 
   ndn::Name m_signingId;
diff --git a/wscript b/wscript
index 025e481..a14b085 100644
--- a/wscript
+++ b/wscript
@@ -30,8 +30,8 @@
 
     boost_libs = 'system iostreams'
     if conf.options._tests:
-        conf.env['_TESTS'] = 1
-        conf.define('_TESTS', 1);
+        conf.env['CHRONOSYNC_HAVE_TESTS'] = 1
+        conf.define('CHRONOSYNC_HAVE_TESTS', 1);
         boost_libs += ' unit_test_framework'
 
     conf.check_boost(lib=boost_libs)
@@ -54,7 +54,7 @@
         )
 
     # Unit tests
-    if bld.env["_TESTS"]:
+    if bld.env["CHRONOSYNC_HAVE_TESTS"]:
         bld.recurse('tests')
 
     bld.install_files(