From a45efd8a72f2c0c6f579daed605aeeb30b836bd4 Mon Sep 17 00:00:00 2001
From: Ingo Ruhnke <grumbel@gmx.de>
Date: Mon, 24 Jan 2011 17:21:50 +0100
Subject: [PATCH] Only cleanup Threads when the try_join was successful

---
 src/xboxdrv_daemon.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/xboxdrv_daemon.cpp b/src/xboxdrv_daemon.cpp
index 48028d2..4cba008 100644
--- a/src/xboxdrv_daemon.cpp
+++ b/src/xboxdrv_daemon.cpp
@@ -68,8 +68,12 @@ XboxdrvDaemon::cleanup_threads()
   {
     if (i->thread)
     {
-      i->thread->try_join_thread();
-      count += 1;
+      if (i->thread->try_join_thread())
+      {
+        delete i->thread;
+        i->thread = 0;
+        count += 1;
+      }
     }
   }