win32: free thread-local data on thread exit

This commit is contained in:
Carlos Martin Nieto 2016-03-18 13:00:27 -07:00 committed by Edward Thomson
parent e97d2d7000
commit a1cf26448a

View File

@ -224,6 +224,20 @@ void git__free_tls_data(void)
TlsSetValue(_tls_index, NULL);
}
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
{
/* This is how Windows lets us know our thread is being shut down */
if (fdwReason == DLL_THREAD_DETACH) {
git__free_tls_data();
}
/*
* Windows pays attention to this during library loading. We don't do anything
* so we trivially succeed.
*/
return TRUE;
}
#elif defined(GIT_THREADS) && defined(_POSIX_THREADS)
static pthread_key_t _tls_key;