From 4eb7a28097bccf07f4e6b8e9f01c058975294643 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Tue, 19 Dec 2023 06:58:05 -0500 Subject: [PATCH 1/6] remove static to make sure plugins libs are unloading during the deactivation --- Source/core/CallsignTLS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index a8e486e34..f4065a9cc 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -48,7 +48,7 @@ namespace Core { template struct CallsignAccess { static const char* Callsign() { - static string modulename(string(_T("??? (Module:"))+*MODULENAME+_T(')')); + string modulename(string(_T("??? (Module:"))+*MODULENAME+_T(')')); const char* callsign = CallsignTLS::Callsign(); if( callsign == nullptr ) { callsign = modulename.c_str(); From 84a65291f2dfe7115e0187b851602446d915bd8d Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Thu, 21 Dec 2023 00:38:46 -0500 Subject: [PATCH 2/6] static module changes --- Source/core/CallsignTLS.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index f4065a9cc..ec6dddfd3 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -48,13 +48,14 @@ namespace Core { template struct CallsignAccess { static const char* Callsign() { - string modulename(string(_T("??? (Module:"))+*MODULENAME+_T(')')); const char* callsign = CallsignTLS::Callsign(); if( callsign == nullptr ) { - callsign = modulename.c_str(); + callsign = _moduleName.c_str(); } return callsign; } + private: + static string _moduleName; }; class EXTERNAL CallSignTLSGuard { @@ -98,6 +99,10 @@ namespace Core { private: string _name; }; + + template + EXTERNAL_HIDDEN string CallsignTLS::CallsignAccess::_moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); + } } From 13358c0ffe036d2818f79e13d2a3c973e67760b0 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Thu, 21 Dec 2023 01:28:20 -0500 Subject: [PATCH 3/6] static module changes --- Source/core/CallsignTLS.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index ec6dddfd3..b0ed44f73 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -101,7 +101,7 @@ namespace Core { }; template - EXTERNAL_HIDDEN string CallsignTLS::CallsignAccess::_moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); + EXTERNAL_HIDDEN string CallsignTLS::CallsignAccess::_moduleName; } From 727ef89fe53c93eb3a97461f4da04b6f432c8670 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Thu, 21 Dec 2023 02:13:21 -0500 Subject: [PATCH 4/6] static module changes --- Source/core/CallsignTLS.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index b0ed44f73..7364e0056 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -48,6 +48,7 @@ namespace Core { template struct CallsignAccess { static const char* Callsign() { + _moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); const char* callsign = CallsignTLS::Callsign(); if( callsign == nullptr ) { callsign = _moduleName.c_str(); From 46dcd7a845804517dbee32180c47f74525695431 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Fri, 22 Dec 2023 00:57:40 -0500 Subject: [PATCH 5/6] CallSignTLS: changes from Pierre's branch --- Source/core/CallsignTLS.cpp | 6 ++-- Source/core/CallsignTLS.h | 57 +++++++++++++++++++------------------ Source/core/SystemInfo.h | 2 +- 3 files changed, 34 insertions(+), 31 deletions(-) diff --git a/Source/core/CallsignTLS.cpp b/Source/core/CallsignTLS.cpp index aa3ee092b..baac18ed7 100644 --- a/Source/core/CallsignTLS.cpp +++ b/Source/core/CallsignTLS.cpp @@ -25,17 +25,17 @@ namespace WPEFramework { namespace Core { - const char* CallsignTLS::Callsign() { + const TCHAR* CallsignTLS::Callsign() { Core::ThreadLocalStorageType& instance = Core::ThreadLocalStorageType::Instance(); - const char* name = nullptr; + const TCHAR* name = nullptr; if( ( instance.IsSet() == true ) && ( instance.Context().Name() != nullptr ) ) { name = instance.Context().Name(); // should be safe, nobody should for this thread be able to change this while we are using it } return name; } - void CallsignTLS::Callsign(const char* callsign) { + void CallsignTLS::Callsign(const TCHAR* callsign) { Core::ThreadLocalStorageType::Instance().Context().Name(callsign); } } diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index 7364e0056..ca2c6da27 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -44,56 +44,60 @@ namespace Core { class EXTERNAL CallsignTLS { public: + CallsignTLS(CallsignTLS&&) = delete; + CallsignTLS(const CallsignTLS&) = delete; + CallsignTLS& operator=(CallsignTLS&&) = delete; + CallsignTLS& operator=(const CallsignTLS&) = delete; - template - struct CallsignAccess { - static const char* Callsign() { - _moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); - const char* callsign = CallsignTLS::Callsign(); - if( callsign == nullptr ) { - callsign = _moduleName.c_str(); - } - return callsign; - } - private: - static string _moduleName; - }; + private: + CallsignTLS() : _name() {}; + ~CallsignTLS() = default; + public: class EXTERNAL CallSignTLSGuard { public: + CallSignTLSGuard(CallSignTLSGuard&&) = delete; CallSignTLSGuard(const CallSignTLSGuard&) = delete; + CallSignTLSGuard& operator=(CallSignTLSGuard&&) = delete; CallSignTLSGuard& operator=(const CallSignTLSGuard&) = delete; - explicit CallSignTLSGuard(const char* callsign) { + explicit CallSignTLSGuard(const TCHAR* callsign) { CallsignTLS::Callsign(callsign); } ~CallSignTLSGuard() { CallsignTLS::Callsign(nullptr); } + }; + + template + struct CallsignAccess { + static const TCHAR* Callsign() { + const TCHAR* callsign = CallsignTLS::Callsign(); + if (callsign == nullptr) { + callsign = _moduleName.c_str(); + } + return callsign; + } + private: + static const string _moduleName; }; - static const char* Callsign(); - static void Callsign(const char* callsign); + static const TCHAR* Callsign(); + static void Callsign(const TCHAR* callsign); private: friend class Core::ThreadLocalStorageType; - CallsignTLS(const CallsignTLS&) = delete; - CallsignTLS& operator=(const CallsignTLS&) = delete; - - CallsignTLS() : _name() {}; - ~CallsignTLS() = default; - - void Name(const char* name) { + void Name(const TCHAR* name) { if ( name != nullptr ) { _name = name; } else { _name.clear(); } } - const char* Name() const { + const TCHAR* Name() const { return ( _name.empty() == false ? _name.c_str() : nullptr ); } @@ -101,9 +105,8 @@ namespace Core { string _name; }; - template - EXTERNAL_HIDDEN string CallsignTLS::CallsignAccess::_moduleName; - + template + EXTERNAL_HIDDEN const string CallsignTLS::CallsignAccess::_moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); } } diff --git a/Source/core/SystemInfo.h b/Source/core/SystemInfo.h index 8da350dda..06ba7fc8b 100644 --- a/Source/core/SystemInfo.h +++ b/Source/core/SystemInfo.h @@ -41,7 +41,7 @@ namespace Core { namespace System { extern "C" const WPEFramework::Core::IServiceMetadata * ROOT_META_DATA; - extern "C" const char* MODULE_NAME; + extern "C" EXTERNAL const char* MODULE_NAME; extern "C" EXTERNAL uint32_t Reboot(); extern "C" EXTERNAL_EXPORT const char* ModuleBuildRef(); From 43dba99ac2ba5be80c1d0f354b7f590023c65d71 Mon Sep 17 00:00:00 2001 From: HaseenaSainul Date: Fri, 22 Dec 2023 00:59:30 -0500 Subject: [PATCH 6/6] CallsignTLS: initialize static from Callsign if it is empty --- Source/core/CallsignTLS.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/core/CallsignTLS.h b/Source/core/CallsignTLS.h index ca2c6da27..3aa205a3a 100644 --- a/Source/core/CallsignTLS.h +++ b/Source/core/CallsignTLS.h @@ -73,6 +73,9 @@ namespace Core { template struct CallsignAccess { static const TCHAR* Callsign() { + if (_moduleName.empty()) { + _moduleName = (string(_T("??? (Module:")) + ((MODULENAME != nullptr) ? *MODULENAME : "UNKNOWN") + _T(')')); + } const TCHAR* callsign = CallsignTLS::Callsign(); if (callsign == nullptr) { callsign = _moduleName.c_str(); @@ -81,7 +84,7 @@ namespace Core { } private: - static const string _moduleName; + static string _moduleName; }; static const TCHAR* Callsign(); @@ -106,7 +109,7 @@ namespace Core { }; template - EXTERNAL_HIDDEN const string CallsignTLS::CallsignAccess::_moduleName = (string(_T("??? (Module:")) + *MODULENAME + _T(')')); + EXTERNAL_HIDDEN string CallsignTLS::CallsignAccess::_moduleName; } }