From f0f2c46fa8952e6f3f0611ea4fc6f8bb583827bd Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Thu, 2 Aug 2012 14:24:40 -0400
Subject: [PATCH] * #14176: video: destory sip_thread_client earlier

---
 daemon/src/sip/sip_thread_client.cpp      | 8 ++++++--
 daemon/src/video/video_receive_thread.cpp | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/daemon/src/sip/sip_thread_client.cpp b/daemon/src/sip/sip_thread_client.cpp
index 5ffd30b1f3..e657e9efd9 100644
--- a/daemon/src/sip/sip_thread_client.cpp
+++ b/daemon/src/sip/sip_thread_client.cpp
@@ -44,7 +44,11 @@ SIPThreadClient::~SIPThreadClient()
 {
     if (thread_) {
         WARN("Destroying thread handle");
-        pj_thread_join(thread_);
-        pj_thread_destroy(thread_);
+        if (pj_thread_join(thread_) != PJ_SUCCESS) {
+            ERROR("Error on thread join");
+        } else if (pj_thread_destroy(thread_) != PJ_SUCCESS) {
+            ERROR("Error on thread destroy");
+        }
+        thread_ = 0;
     }
 }
diff --git a/daemon/src/video/video_receive_thread.cpp b/daemon/src/video/video_receive_thread.cpp
index 953a457e95..1bb48f46ca 100644
--- a/daemon/src/video/video_receive_thread.cpp
+++ b/daemon/src/video/video_receive_thread.cpp
@@ -285,12 +285,12 @@ void VideoReceiveThread::run()
         }
         yield();
     }
-    sipThreadClient_.reset();
 }
 
 VideoReceiveThread::~VideoReceiveThread()
 {
     receiving_ = false;
+    sipThreadClient_.reset(0);
     Manager::instance().getVideoControls()->stoppedDecoding(id_, sink_.openedName());
     ost::Thread::terminate();
 
-- 
GitLab