Global destructor clean-ups and python test fixes
[invirt/third/libt4.git] / handle.cc
index 926cb59..20438f9 100644 (file)
--- a/handle.cc
+++ b/handle.cc
@@ -12,6 +12,16 @@ public:
 static std::mutex mgr_mutex;
 static std::map<string, shared_ptr<hinfo>> hmap;
 
+void handle::shutdown() {
+    lock ml(mgr_mutex);
+    LOG_NONMEMBER << "Shutting down handle manager";
+    for (auto p : hmap) {
+        p.second->valid = false;
+        LOG_NONMEMBER << "cl " << p.first << " refcnt " << p.second.use_count();
+    }
+    hmap.clear();
+}
+
 handle::handle(const string & destination) : destination_(destination) {
     lock ml(mgr_mutex);
     h = hmap[destination];