]> git.cworth.org Git - apitrace/commitdiff
retrace: Join with runner threads before destroy runner objects.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 10 May 2013 16:17:38 +0000 (17:17 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 10 May 2013 16:18:09 +0000 (17:18 +0100)
This fixes segfaults when exiting on windows.

common/os_thread.hpp
retrace/retrace_main.cpp

index 51ac54f3864d6ddf69b94d4413bd124e184c8707..f3ae210053da2b08ef711f516a92a3be433860b1 100644 (file)
@@ -374,6 +374,10 @@ namespace os {
         {
         }
 
+        inline
+        ~thread() {
+        }
+
         template< class Function, class Arg >
         explicit thread( Function& f, Arg arg ) {
 #ifdef _WIN32
@@ -384,6 +388,12 @@ namespace os {
 #endif
         }
 
+        inline thread &
+        operator =(const thread &other) {
+            _native_handle = other._native_handle;
+            return *this;
+        }
+
         inline bool
         joinable(void) const {
             return _native_handle != 0;
index 492deca4a921f822c2404bdb474b5c480e470606..5e31c020490ab86beccb3635914fa82d9e83d479 100644 (file)
@@ -284,6 +284,12 @@ public:
         }
     }
 
+    ~RelayRunner() {
+        if (thread.joinable()) {
+            thread.join();
+        }
+    }
+
     /**
      * Thread main loop.
      */