Ejemplo n.º 1
0
int git_libgit2_shutdown(void)
{
	int ret;

	/* Enter the lock */
	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) {
		shutdown_common();

		git__free_tls_data();

		TlsFree(_tls_index);
		git_mutex_free(&git__mwindow_mutex);

#if defined(GIT_MSVC_CRTDBG)
		git_win32__crtdbg_stacktrace_cleanup();
		git_win32__stack_cleanup();
#endif
	}

	/* Exit the lock */
	InterlockedExchange(&_mutex, 0);

	return ret;
}
Ejemplo n.º 2
0
static void synchronized_threads_shutdown(void)
{
	/* Shut down any subsystems that have global state */
	git__shutdown();

	git__free_tls_data();

	TlsFree(_tls_index);
	git_mutex_free(&git__mwindow_mutex);
}
Ejemplo n.º 3
0
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
{
	GIT_UNUSED(hInstDll);
	GIT_UNUSED(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;
}