mirror of
https://gitee.com/openharmony/communication_ipc
synced 2024-11-24 00:09:51 +00:00
fix:Add lock protection to Invoke rFactory destructor
Signed-off-by: chenchong_666 <chenchong57@huawei.com>
This commit is contained in:
parent
e7a498cdba
commit
1ea804d951
@ -37,7 +37,7 @@ private:
|
||||
InvokerFactory(const InvokerFactory &) = delete;
|
||||
InvokerFactory();
|
||||
~InvokerFactory();
|
||||
static bool isAvailable_;
|
||||
static std::atomic<bool> isAvailable_;
|
||||
std::mutex factoryMutex_;
|
||||
std::unordered_map<int, InvokerCreator> creators_;
|
||||
};
|
||||
|
@ -27,12 +27,13 @@ namespace OHOS {
|
||||
#ifdef CONFIG_IPC_SINGLE
|
||||
namespace IPC_SINGLE {
|
||||
#endif
|
||||
bool InvokerFactory::isAvailable_ = true;
|
||||
std::atomic<bool> InvokerFactory::isAvailable_ = true;
|
||||
|
||||
InvokerFactory::InvokerFactory() {}
|
||||
|
||||
InvokerFactory::~InvokerFactory()
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(factoryMutex_);
|
||||
isAvailable_ = false;
|
||||
creators_.clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user