From: Piotr Kosko/Tizen API (PLT) /SRPOL/Engineer/Samsung Electronics
Date: Mon, 14 Mar 2022 10:46:24 +0000 (+0100)
Subject: [Common] Changed method of deviced listener implementation
X-Git-Tag: accepted/tizen/unified/20220325.133310~2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d9db8580a58bc7959d755cd361c588327723f5d7;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git
[Common] Changed method of deviced listener implementation
To prevent crash in multithreaded model of wrt-services, there is a need
to use device_changed_callback_ as a thread local variable.
[Verification] Code compiles without errors.
Change-Id: Ifba2cef597e6244ab9c071b10c870b942b500946
---
diff --git a/src/common/filesystem/filesystem_provider_deviced.cc b/src/common/filesystem/filesystem_provider_deviced.cc
index 60bc109..9bfb5ea 100644
--- a/src/common/filesystem/filesystem_provider_deviced.cc
+++ b/src/common/filesystem/filesystem_provider_deviced.cc
@@ -54,6 +54,7 @@ bool isExternalStorageSupported() {
return true;
}
+thread_local common::DeviceChangeStateFun device_changed_callback_;
} // namespace
namespace common {
@@ -122,7 +123,6 @@ FilesystemProviderDeviced::~FilesystemProviderDeviced() {
FilesystemProviderDeviced::FilesystemProviderDeviced()
: dbus_(nullptr),
proxy_(nullptr),
- device_changed_callback_(nullptr),
block_signal_subscribe_id_(0),
virtual_roots_provider_(FilesystemProviderStorage::Create()),
is_initialized_(false) {
@@ -190,7 +190,7 @@ void FilesystemProviderDeviced::RegisterDeviceChangeState(DeviceChangeStateFun _
return;
}
- if (device_changed_callback_ == nullptr) {
+ if (0 == block_signal_subscribe_id_) {
LoggerD("Registering dbus signal subscription");
block_signal_subscribe_id_ = g_dbus_connection_signal_subscribe(
dbus_, nullptr, kBlockManagerIface, kDeviceChangedMethod, nullptr, nullptr,
diff --git a/src/common/filesystem/filesystem_provider_deviced.h b/src/common/filesystem/filesystem_provider_deviced.h
index 65746b8..4491c12 100644
--- a/src/common/filesystem/filesystem_provider_deviced.h
+++ b/src/common/filesystem/filesystem_provider_deviced.h
@@ -60,7 +60,6 @@ class FilesystemProviderDeviced : public IFilesystemProvider {
GDBusConnection* dbus_;
GDBusProxy* proxy_;
- DeviceChangeStateFun device_changed_callback_;
guint block_signal_subscribe_id_;
std::map previous_device_state_map_;
FilesystemProviderRef virtual_roots_provider_;