diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-06-19 15:57:03 +0300 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2019-06-19 15:57:03 +0300 |
commit | a74ea1811640f2647a1f6dd15663167dfdbe00ab (patch) | |
tree | 4928ff9fb0010674e0abf0498662986a8f2a67dd /indra/newview/llmachineid.cpp | |
parent | 55670eef350c9db849eab8b813ca7335fdec3435 (diff) |
DRTVWR-493 LLMachineId to singleton
Diffstat (limited to 'indra/newview/llmachineid.cpp')
-rw-r--r-- | indra/newview/llmachineid.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp index b0ee8e7fcb..1420161008 100644 --- a/indra/newview/llmachineid.cpp +++ b/indra/newview/llmachineid.cpp @@ -34,8 +34,6 @@ using namespace std; #include <comdef.h> #include <Wbemidl.h> #endif -unsigned char static_unique_id[] = {0,0,0,0,0,0}; -bool static has_static_unique_id = false; #if LL_WINDOWS @@ -60,16 +58,22 @@ public: #endif //LL_WINDOWS // get an unique machine id. -// NOT THREAD SAFE - do before setting up threads. +// NOT THREAD SAFE - do first call before setting up threads. // MAC Address doesn't work for Windows 7 since the first returned hardware MAC address changes with each reboot, Go figure?? +LLMachineID::LLMachineID() : +mHasStaticUniqueId(false) +{ + // will set mStaticUniqueId to 0 + requestUniqueID(); +} -S32 LLMachineID::init() +S32 LLMachineID::requestUniqueID() { - memset(static_unique_id,0,sizeof(static_unique_id)); + memset(mStaticUniqueId, 0, sizeof(mStaticUniqueId)); S32 ret_code = 0; #if LL_WINDOWS # pragma comment(lib, "wbemuuid.lib") - size_t len = sizeof(static_unique_id); + size_t len = sizeof(mStaticUniqueId); // algorithm to detect BIOS serial number found at: // http://msdn.microsoft.com/en-us/library/aa394077%28VS.85%29.aspx @@ -228,7 +232,7 @@ S32 LLMachineID::init() if (vtProp.bstrVal[j] == 0) break; - static_unique_id[i] = (unsigned int)(static_unique_id[i] + serialNumber[j]); + mStaticUniqueId[i] = (unsigned int)(mStaticUniqueId[i] + serialNumber[j]); j++; } } @@ -253,16 +257,16 @@ S32 LLMachineID::init() unsigned char * staticPtr = (unsigned char *)(&static_unique_id[0]); ret_code = LLUUID::getNodeID(staticPtr); #endif - has_static_unique_id = true; + mHasStaticUniqueId = true; return ret_code; } S32 LLMachineID::getUniqueID(unsigned char *unique_id, size_t len) { - if (has_static_unique_id) + if (mHasStaticUniqueId) { - memcpy ( unique_id, &static_unique_id, len); + memcpy(unique_id, &mStaticUniqueId, len); LL_INFOS_ONCE("AppInit") << "UniqueID: 0x"; // Code between here and LL_ENDL is not executed unless the LL_DEBUGS // actually produces output |