From Mathias Froehlich, "An other one:
The TLS Varialbe is accessed before it is initialized. Attached is a change to rev 9791." Merged from svn/trunk using: svn merge -r 9831:9832 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk/src/OpenThreads/win32
This commit is contained in:
@@ -98,7 +98,7 @@ namespace OpenThreads {
|
||||
|
||||
if (thread->_prvData==0) return 0;
|
||||
|
||||
TlsSetValue(Win32ThreadPrivateData::TLS.ID ,data);
|
||||
TlsSetValue(Win32ThreadPrivateData::TLS.getId(), data);
|
||||
//---------------------------------------------------------------------
|
||||
// Set the proper scheduling priorities
|
||||
//
|
||||
@@ -127,6 +127,7 @@ namespace OpenThreads {
|
||||
// abnormal termination but must be caught in win32 anyway
|
||||
}
|
||||
|
||||
TlsSetValue(Win32ThreadPrivateData::TLS.getId(), 0);
|
||||
pd->isRunning = false;
|
||||
|
||||
return 0;
|
||||
@@ -207,7 +208,7 @@ namespace OpenThreads {
|
||||
|
||||
Thread* Thread::CurrentThread()
|
||||
{
|
||||
return (Thread* )TlsGetValue(Win32ThreadPrivateData::TLS.ID);
|
||||
return (Thread* )TlsGetValue(Win32ThreadPrivateData::TLS.getId());
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -69,12 +69,20 @@ public:
|
||||
HandleHolder cancelEvent;
|
||||
|
||||
struct TlsHolder{ // thread local storage slot
|
||||
DWORD ID;
|
||||
TlsHolder(): ID(TlsAlloc()){
|
||||
DWORD getId()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
ID = TlsAlloc();
|
||||
initialized = true;
|
||||
}
|
||||
return ID;
|
||||
}
|
||||
~TlsHolder(){
|
||||
TlsFree(ID);
|
||||
}
|
||||
private:
|
||||
DWORD ID;
|
||||
};
|
||||
|
||||
static TlsHolder TLS;
|
||||
|
||||
Reference in New Issue
Block a user