From d7f6d516cefed79dea14465abd7c2a0f036f78b9 Mon Sep 17 00:00:00 2001
From: bunnei <bunneidev@gmail.com>
Date: Sun, 5 Dec 2021 23:42:58 -0800
Subject: [PATCH] hle: kernel: service_thread: Force stop threads on
 destruction.

---
 src/core/hle/kernel/service_thread.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/core/hle/kernel/service_thread.cpp b/src/core/hle/kernel/service_thread.cpp
index 00657bc4c1..03f3dec104 100644
--- a/src/core/hle/kernel/service_thread.cpp
+++ b/src/core/hle/kernel/service_thread.cpp
@@ -97,7 +97,13 @@ void ServiceThread::Impl::QueueSyncRequest(KSession& session,
     condition.notify_one();
 }
 
-ServiceThread::Impl::~Impl() = default;
+ServiceThread::Impl::~Impl() {
+    condition.notify_all();
+    for (auto& thread : threads) {
+        thread.request_stop();
+        thread.join();
+    }
+}
 
 ServiceThread::ServiceThread(KernelCore& kernel, std::size_t num_threads, const std::string& name)
     : impl{std::make_unique<Impl>(kernel, num_threads, name)} {}