diff options
author | joshaber <joshaber@gmail.com> | 2015-07-22 11:33:18 -0400 |
---|---|---|
committer | joshaber <joshaber@gmail.com> | 2015-07-22 11:33:18 -0400 |
commit | 9830fbba05ef66325f929a09407abc45ab85847d (patch) | |
tree | dac363428f4705a632719e03b8b77f2d32ce2bb3 /src/global.c | |
parent | cf198fdf2a044d2e2f0675c2c6b1cd9cdbcf4fcf (diff) | |
parent | 42156d561723e92ffe597885719aa63abfe0795c (diff) | |
download | libgit2-fix-init-ordering.tar.gz |
Merge branch 'master' into fix-init-orderingfix-init-ordering
Diffstat (limited to 'src/global.c')
-rw-r--r-- | src/global.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/global.c b/src/global.c index cb2242405..37a47bd27 100644 --- a/src/global.c +++ b/src/global.c @@ -11,7 +11,10 @@ #include "git2/global.h" #include "git2/sys/openssl.h" #include "thread-utils.h" - +#if defined(GIT_MSVC_CRTDBG) +#include "win32/w32_stack.h" +#include "win32/w32_crtdbg_stacktrace.h" +#endif git_mutex git__mwindow_mutex; @@ -225,6 +228,11 @@ int git_libgit2_init(void) /* Only do work on a 0 -> 1 transition of the refcount */ if ((ret = git_atomic_inc(&git__n_inits)) == 1) { +#if defined(GIT_MSVC_CRTDBG) + git_win32__crtdbg_stacktrace_init(); + git_win32__stack_init(); +#endif + if (synchronized_threads_init() < 0) ret = -1; } @@ -254,9 +262,15 @@ int git_libgit2_shutdown(void) while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 1 -> 0 transition of the refcount */ - if ((ret = git_atomic_dec(&git__n_inits)) == 0) + if ((ret = git_atomic_dec(&git__n_inits)) == 0) { synchronized_threads_shutdown(); +#if defined(GIT_MSVC_CRTDBG) + git_win32__crtdbg_stacktrace_cleanup(); + git_win32__stack_cleanup(); +#endif + } + /* Exit the lock */ InterlockedExchange(&_mutex, 0); |