mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-31 02:18:08 +00:00
unload dll / destroy hash ctxs at shutdown
This commit is contained in:
parent
7ebefd22e7
commit
a8527429dc
@ -79,6 +79,9 @@ void git_threads_shutdown(void)
|
|||||||
TlsFree(_tls_index);
|
TlsFree(_tls_index);
|
||||||
_tls_init = 0;
|
_tls_init = 0;
|
||||||
git_mutex_free(&git__mwindow_mutex);
|
git_mutex_free(&git__mwindow_mutex);
|
||||||
|
|
||||||
|
/* Shut down any subsystems that have global state */
|
||||||
|
git_hash_global_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
git_global_st *git__global_state(void)
|
git_global_st *git__global_state(void)
|
||||||
@ -131,6 +134,9 @@ void git_threads_shutdown(void)
|
|||||||
{
|
{
|
||||||
pthread_key_delete(_tls_key);
|
pthread_key_delete(_tls_key);
|
||||||
_tls_init = 0;
|
_tls_init = 0;
|
||||||
|
|
||||||
|
/* Shut down any subsystems that have global state */
|
||||||
|
git_hash_global_shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
git_global_st *git__global_state(void)
|
git_global_st *git__global_state(void)
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# define GIT_MEMORY_BARRIER MemoryBarrier()
|
# define GIT_MEMORY_BARRIER MemoryBarrier()
|
||||||
#elif defined(GIT_THREADS)
|
#elif defined(GIT_THREADS)
|
||||||
# define GIT_MEMORY_BARRIER __sync_synchronize()
|
# define GIT_MEMORY_BARRIER __sync_synchronize()
|
||||||
|
#else
|
||||||
|
# define GIT_MEMORY_BARRIER /* noop */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -13,6 +13,7 @@ typedef struct git_hash_prov git_hash_prov;
|
|||||||
typedef struct git_hash_ctx git_hash_ctx;
|
typedef struct git_hash_ctx git_hash_ctx;
|
||||||
|
|
||||||
int git_hash_global_init(void);
|
int git_hash_global_init(void);
|
||||||
|
void git_hash_global_shutdown(void);
|
||||||
|
|
||||||
int git_hash_ctx_init(git_hash_ctx *ctx);
|
int git_hash_ctx_init(git_hash_ctx *ctx);
|
||||||
void git_hash_ctx_cleanup(git_hash_ctx *ctx);
|
void git_hash_ctx_cleanup(git_hash_ctx *ctx);
|
||||||
|
@ -17,6 +17,7 @@ struct git_hash_ctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define git_hash_global_init() 0
|
#define git_hash_global_init() 0
|
||||||
|
#define git_hash_global_shutdown() /* noop */
|
||||||
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
||||||
#define git_hash_ctx_cleanup(ctx)
|
#define git_hash_ctx_cleanup(ctx)
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ struct git_hash_ctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define git_hash_global_init() 0
|
#define git_hash_global_init() 0
|
||||||
|
#define git_hash_global_shutdown() /* noop */
|
||||||
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
||||||
#define git_hash_ctx_cleanup(ctx)
|
#define git_hash_ctx_cleanup(ctx)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ struct git_hash_ctx {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define git_hash_global_init() 0
|
#define git_hash_global_init() 0
|
||||||
|
#define git_hash_global_shutdown() /* noop */
|
||||||
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
#define git_hash_ctx_init(ctx) git_hash_init(ctx)
|
||||||
#define git_hash_ctx_cleanup(ctx)
|
#define git_hash_ctx_cleanup(ctx)
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|||||||
char dll_path[MAX_PATH];
|
char dll_path[MAX_PATH];
|
||||||
DWORD dll_path_len, size_len;
|
DWORD dll_path_len, size_len;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
|
/* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */
|
||||||
version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||||
version_test.dwMajorVersion = 6;
|
version_test.dwMajorVersion = 6;
|
||||||
@ -79,6 +81,14 @@ GIT_INLINE(int) hash_cng_prov_init(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIT_INLINE(void) hash_cng_prov_shutdown(void)
|
||||||
|
{
|
||||||
|
hash_prov.prov.cng.close_algorithm_provider(hash_prov.prov.cng.handle, 0);
|
||||||
|
FreeLibrary(hash_prov.prov.cng.dll);
|
||||||
|
|
||||||
|
hash_prov.type = INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize CryptoAPI */
|
/* Initialize CryptoAPI */
|
||||||
GIT_INLINE(int) hash_cryptoapi_prov_init()
|
GIT_INLINE(int) hash_cryptoapi_prov_init()
|
||||||
{
|
{
|
||||||
@ -89,6 +99,13 @@ GIT_INLINE(int) hash_cryptoapi_prov_init()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIT_INLINE(void) hash_cryptoapi_prov_shutdown(void)
|
||||||
|
{
|
||||||
|
CryptReleaseContext(hash_prov.prov.cryptoapi.handle, 0);
|
||||||
|
|
||||||
|
hash_prov.type = INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
int git_hash_global_init()
|
int git_hash_global_init()
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@ -102,6 +119,14 @@ int git_hash_global_init()
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void git_hash_global_shutdown()
|
||||||
|
{
|
||||||
|
if (hash_prov.type == CNG)
|
||||||
|
hash_cng_prov_shutdown();
|
||||||
|
else if(hash_prov.type == CRYPTOAPI)
|
||||||
|
hash_cryptoapi_prov_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
/* CryptoAPI: available in Windows XP and newer */
|
/* CryptoAPI: available in Windows XP and newer */
|
||||||
|
|
||||||
GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx)
|
GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx)
|
||||||
|
Loading…
Reference in New Issue
Block a user