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; }
int git_libgit2_shutdown(void) { void *ptr = NULL; pthread_once_t new_once = PTHREAD_ONCE_INIT; int error, ret; if ((error = pthread_mutex_lock(&_init_mutex)) != 0) return error; if ((ret = git_atomic_dec(&git__n_inits)) != 0) goto out; /* Shut down any subsystems that have global state */ shutdown_common(); ptr = pthread_getspecific(_tls_key); pthread_setspecific(_tls_key, NULL); git__global_state_cleanup(ptr); git__free(ptr); pthread_key_delete(_tls_key); git_mutex_free(&git__mwindow_mutex); _once_init = new_once; out: if ((error = pthread_mutex_unlock(&_init_mutex)) != 0) return error; return ret; }
static void synchronized_threads_shutdown(void) { /* Shut down any subsystems that have global state */ git__shutdown(); TlsFree(_tls_index); git_mutex_free(&git__mwindow_mutex); }
int git_libgit2_shutdown(void) { void *ptr = NULL; pthread_once_t new_once = PTHREAD_ONCE_INIT; int ret; if ((ret = git_atomic_dec(&git__n_inits)) != 0) return ret; /* Shut down any subsystems that have global state */ git__shutdown(); uninit_ssl(); ptr = pthread_getspecific(_tls_key); pthread_setspecific(_tls_key, NULL); git__global_state_cleanup(ptr); git__free(ptr); pthread_key_delete(_tls_key); git_mutex_free(&git__mwindow_mutex); _once_init = new_once; return 0; }
void git_threads_shutdown(void) { TlsFree(_tls_index); _tls_init = 0; git_mutex_free(&git__mwindow_mutex); /* Shut down any subsystems that have global state */ git_hash_global_shutdown(); git_futils_dirs_free(); }
static void shutdown_ssl_locking(void) { int num_locks, i; num_locks = CRYPTO_num_locks(); CRYPTO_set_locking_callback(NULL); for (i = 0; i < num_locks; ++i) git_mutex_free(openssl_locks); git__free(openssl_locks); }
static void attr_file_free(git_attr_file *file) { bool unlock = !git_mutex_lock(&file->lock); git_attr_file__clear_rules(file, false); git_pool_clear(&file->pool); if (unlock) git_mutex_unlock(&file->lock); git_mutex_free(&file->lock); git__memzero(file, sizeof(*file)); git__free(file); }
void git_cache_free(git_cache *cache) { size_t i; for (i = 0; i < (cache->size_mask + 1); ++i) { if (cache->nodes[i].ptr) git_cached_obj_decref(cache->nodes[i].ptr, cache->free_obj); git_mutex_free(&cache->nodes[i].lock); } free(cache->nodes); }
void git_threads_shutdown(void) { if (_tls_init) { void *ptr = pthread_getspecific(_tls_key); pthread_setspecific(_tls_key, NULL); git__free(ptr); } pthread_key_delete(_tls_key); _tls_init = 0; git_mutex_free(&git__mwindow_mutex); /* Shut down any subsystems that have global state */ git_hash_global_shutdown(); git_futils_dirs_free(); }
void git_threads_shutdown(void) { void *ptr = NULL; pthread_once_t new_once = PTHREAD_ONCE_INIT; if (git_atomic_dec(&git__n_inits) > 0) return; /* Shut down any subsystems that have global state */ git__shutdown(); ptr = pthread_getspecific(_tls_key); pthread_setspecific(_tls_key, NULL); git__free(ptr); pthread_key_delete(_tls_key); git_mutex_free(&git__mwindow_mutex); _once_init = new_once; }