mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-12-01 17:41:12 +00:00
fix(linux/portalgrab): don't use TaskPool for xdg_worker thread. (#5822)
This commit is contained in:
1 parent
8fc40974c9
commit
1222ff62ab
4 files changed
+55
-15
No files matched your search
@@ -1270,12 +1270,21 @@ namespace platf {
|
||||
case no_token:
|
||||
BOOST_LOG(fatal) << "Portal capture is awaiting user permission. "sv
|
||||
<< "The current session will attempt to use a fallback capture method."sv;
|
||||
task_pool.push([]() {
|
||||
if (!portal_display_names(false).empty()) {
|
||||
platf::restart();
|
||||
} else {
|
||||
BOOST_LOG(error) << "[portalgrab] Portal session token was not negotiated."sv;
|
||||
}
|
||||
std::call_once(portal::xdg_worker_flag, []() {
|
||||
portal::xdg_worker = std::jthread([]() {
|
||||
try {
|
||||
platf::set_thread_name("xdg_worker");
|
||||
if (!portal_display_names(false).empty()) {
|
||||
platf::restart();
|
||||
} else {
|
||||
BOOST_LOG(error) << "[portalgrab] Portal session token was not negotiated."sv;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
BOOST_LOG(error) << "[portalgrab] Exception caught in xdg_worker: "sv << e.what();
|
||||
} catch (...) {
|
||||
BOOST_LOG(error) << "[portalgrab] Unknown exception caught in xdg_worker"sv;
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
default:
|
||||
@@ -1489,6 +1498,28 @@ namespace platf {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef SUNSHINE_BUILD_PORTAL
|
||||
class deinit_t: public platf::deinit_t {
|
||||
public:
|
||||
/**
|
||||
* @brief Handle xdg_worker thread cleanup in destructor.
|
||||
*/
|
||||
~deinit_t() override {
|
||||
try {
|
||||
if (portal::xdg_worker.joinable()) {
|
||||
// Make sure the worker's response loop sees shutdown before we block on join().
|
||||
if (mail::man) {
|
||||
mail::man->event<bool>(mail::shutdown)->raise(true);
|
||||
}
|
||||
portal::xdg_worker.join();
|
||||
}
|
||||
} catch (const std::exception &err) {
|
||||
BOOST_LOG(error) << "[portalgrab] Exception while joining xdg_worker: "sv << err.what();
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
return std::make_unique<deinit_t>();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user