When app is launched, ApplicationData instance maybe is created
by multi-threads(main thread, prelaunch worker, reallaunch worker)
at the same time.
So add lock in ApplicationData::GetInstance.
Reference:
https://review.tizen.org/gerrit/#/c/platform/framework/web/chromium-efl/+/304102/
Change-Id: I883711947700e3cc973f2ad2ce4deee989708517
Signed-off-by: DongHyun Song <dh81.song@samsung.com>
std::map<std::string, std::string> pkg_paths_;
std::string wrt_res_path_;
base::Lock data_lock_;
+base::Lock instance_lock_;
static ApplicationData* instance = nullptr;
// static
ApplicationData& ApplicationData::GetInstance() {
- if (!instance)
+ if (!instance) {
+ base::AutoLock lock(instance_lock_);
+ if (!instance) // double check to avoid create instance again
#if BUILDFLAG(IS_TIZEN_TV)
- instance = new ApplicationDataTV;
+ instance = new ApplicationDataTV;
#else
- instance = new ApplicationData;
+ instance = new ApplicationData;
#endif
+ }
return *instance;
}