From: José Fonseca Date: Fri, 10 May 2013 16:17:38 +0000 (+0100) Subject: retrace: Join with runner threads before destroy runner objects. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=e04a310cbaf02782fab6f62269eacd17911a72cc;p=apitrace retrace: Join with runner threads before destroy runner objects. This fixes segfaults when exiting on windows. --- diff --git a/common/os_thread.hpp b/common/os_thread.hpp index 51ac54f..f3ae210 100644 --- a/common/os_thread.hpp +++ b/common/os_thread.hpp @@ -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; diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp index 492deca..5e31c02 100644 --- a/retrace/retrace_main.cpp +++ b/retrace/retrace_main.cpp @@ -284,6 +284,12 @@ public: } } + ~RelayRunner() { + if (thread.joinable()) { + thread.join(); + } + } + /** * Thread main loop. */