From c28426a09f57444eb8c772dac367c3ac33b163be Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Tue, 6 Jan 2015 20:29:47 +0000 Subject: [PATCH] Fix threads leaking if they're not joined. (bug 3460, r=dvander) --- public/amtl/am-thread-posix.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/amtl/am-thread-posix.h b/public/amtl/am-thread-posix.h index bc654261..c5d1b25c 100644 --- a/public/amtl/am-thread-posix.h +++ b/public/amtl/am-thread-posix.h @@ -174,6 +174,11 @@ class Thread if (!initialized_) delete data; } + ~Thread() { + if (!Succeeded()) + return; + pthread_detach(thread_); + } bool Succeeded() const { return initialized_; @@ -183,6 +188,7 @@ class Thread if (!Succeeded()) return; pthread_join(thread_, NULL); + initialized_ = false; } private: