summaryrefslogtreecommitdiff
path: root/src/win32
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-09-11 12:45:20 -0700
committerRussell Belfer <rb@github.com>2013-09-17 09:31:45 -0700
commita3aa5f4d5dcbe038f1d1c5ff40eed29d27953fbe (patch)
tree6ef7a6b5bdfc26e10279c2629f58036f4025f199 /src/win32
parente7d0ced2192c5efeea6d9f5667d366891010b86a (diff)
downloadlibgit2-a3aa5f4d5dcbe038f1d1c5ff40eed29d27953fbe.tar.gz
Add simple global shutdown hooks
Increasingly there are a number of components that want to do some cleanup at global shutdown time (at least if there are not going to be memory leaks). This creates a very simple system of shutdown hooks that will be invoked by git_threads_shutdown. Right now, the maximum number of hooks is hardcoded, but since adding a hook is not a public API, it should be fine and I thought it was better to start off with really simple code.
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/pthread.c18
-rw-r--r--src/win32/pthread.h1
2 files changed, 9 insertions, 10 deletions
diff --git a/src/win32/pthread.c b/src/win32/pthread.c
index d50ace695..8c7ef2856 100644
--- a/src/win32/pthread.c
+++ b/src/win32/pthread.c
@@ -217,6 +217,14 @@ int pthread_rwlock_destroy(pthread_rwlock_t *lock)
}
+static void win32_pthread_shutdown(void)
+{
+ if (win32_kernel32_dll) {
+ FreeLibrary(win32_kernel32_dll);
+ win32_kernel32_dll = NULL;
+ }
+}
+
int win32_pthread_initialize(void)
{
if (win32_kernel32_dll)
@@ -239,15 +247,7 @@ int win32_pthread_initialize(void)
win32_srwlock_release_exclusive = (win32_srwlock_fn)
GetProcAddress(win32_kernel32_dll, "ReleaseSRWLockExclusive");
- return 0;
-}
-
-int win32_pthread_shutdown(void)
-{
- if (win32_kernel32_dll) {
- FreeLibrary(win32_kernel32_dll);
- win32_kernel32_dll = NULL;
- }
+ git__on_shutdown(win32_pthread_shutdown);
return 0;
}
diff --git a/src/win32/pthread.h b/src/win32/pthread.h
index 2ba2ca552..af5b121f0 100644
--- a/src/win32/pthread.h
+++ b/src/win32/pthread.h
@@ -69,6 +69,5 @@ int pthread_rwlock_wrunlock(pthread_rwlock_t *);
int pthread_rwlock_destroy(pthread_rwlock_t *);
extern int win32_pthread_initialize(void);
-extern int win32_pthread_shutdown(void);
#endif