diff options
author | Carlos Martin Nieto <cmn@dwim.me> | 2016-03-18 13:00:27 -0700 |
---|---|---|
committer | Carlos Martin Nieto <cmn@dwim.me> | 2016-03-18 13:05:10 -0700 |
commit | a177756b34e7fe9472ec9a6a92805add70cd6815 (patch) | |
tree | e37c3f21bb44fde69b8cffb66d271cee15200c02 /src/global.c | |
parent | de143efa88f6916af62cc5ed172e9cae4b194ae1 (diff) | |
download | libgit2-a177756b34e7fe9472ec9a6a92805add70cd6815.tar.gz |
win32: free thread-local data on thread exitcmn/win32-free-tls
Diffstat (limited to 'src/global.c')
-rw-r--r-- | src/global.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/global.c b/src/global.c index c725b5184..adf353d35 100644 --- a/src/global.c +++ b/src/global.c @@ -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; |