From fdeffa0e2b3d678bc39c1eab829c4db7b476a33f Mon Sep 17 00:00:00 2001 From: paulc Date: Tue, 13 Jun 2006 20:38:44 +0000 Subject: [PATCH] Fixed init order on Win2000 Advanced Server. Added missing project file for analyzer channel. git-svn-id: http://yate.null.ro/svn/yate/trunk@864 acf43c95-373e-0410-b603-e72c3f656dc1 --- engine/Thread.cpp | 18 +++++-- windows/YATE.dsw | 18 +++++++ windows/_analyzer.dsp | 114 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 windows/_analyzer.dsp diff --git a/engine/Thread.cpp b/engine/Thread.cpp index 7676559c..ecd108ba 100644 --- a/engine/Thread.cpp +++ b/engine/Thread.cpp @@ -76,7 +76,19 @@ using namespace TelEngine; #define KILL_WAIT 32 #ifdef _WINDOWS -static DWORD tls_index = ::TlsAlloc(); +#define TLS_MAGIC 0xfeeb1e +static DWORD tls_index = TLS_MAGIC; +static DWORD getTls() +{ + // this seems unsafe but is not - allocation happens once before + // any Thread is actually created + if (tls_index == TLS_MAGIC) + tls_index = ::TlsAlloc(); + if (tls_index == (DWORD)-1) + // if it happened is REALLY BAD so better die quick and clean! + abort(); + return tls_index; +} #else static pthread_key_t current_key; @@ -254,7 +266,7 @@ void ThreadPrivate::run() { DDebug(DebugAll,"ThreadPrivate::run() '%s' [%p]",m_name,this); #ifdef _WINDOWS - ::TlsSetValue(tls_index,this); + ::TlsSetValue(getTls(),this); #else ::pthread_setspecific(current_key,this); pthread_cleanup_push(cleanupFunc,this); @@ -329,7 +341,7 @@ void ThreadPrivate::cleanup() ThreadPrivate* ThreadPrivate::current() { #ifdef _WINDOWS - return reinterpret_cast(::TlsGetValue(tls_index)); + return reinterpret_cast(::TlsGetValue(getTls())); #else return reinterpret_cast(::pthread_getspecific(current_key)); #endif diff --git a/windows/YATE.dsw b/windows/YATE.dsw index 2193b3d0..0bef35f3 100644 --- a/windows/YATE.dsw +++ b/windows/YATE.dsw @@ -212,6 +212,9 @@ Package=<4> Begin Project Dependency Project_Dep_Name _pbxassist End Project Dependency + Begin Project Dependency + Project_Dep_Name _analyzer + End Project Dependency }}} ############################################################################### @@ -291,6 +294,21 @@ Package=<4> ############################################################################### +Project: "_analyzer"=.\_analyzer.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name Libyate + End Project Dependency +}}} + +############################################################################### + Project: "_callfork"=.\_callfork.dsp - Package Owner=<4> Package=<5> diff --git a/windows/_analyzer.dsp b/windows/_analyzer.dsp new file mode 100644 index 00000000..017b6858 --- /dev/null +++ b/windows/_analyzer.dsp @@ -0,0 +1,114 @@ +# Microsoft Developer Studio Project File - Name="_analyzer" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=_analyzer - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "_analyzer.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "_analyzer.mak" CFG="_analyzer - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "_analyzer - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "_analyzer - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "_analyzer - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release\modules" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_analyzer_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /O2 /I "." /I ".." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FD /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib /nologo /dll /machine:I386 /out:"Release/analyzer.yate" +# SUBTRACT LINK32 /incremental:yes + +!ELSEIF "$(CFG)" == "_analyzer - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug\modules" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_analyzer_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /Zi /Od /I "." /I ".." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FD /GZ /c +# SUBTRACT CPP /YX +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib /nologo /dll /incremental:no /debug /machine:I386 /out:"Debug/analyzer.yate" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "_analyzer - Win32 Release" +# Name "_analyzer - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\modules\analyzer.cpp +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# Begin Source File + +SOURCE=.\version.rc +# End Source File +# End Group +# End Target +# End Project