diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2012-11-13 14:48:10 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2012-11-13 14:48:10 -0600 |
| commit | a8527429dc48ce0f9b63789715ed8eaa9b1abf0d (patch) | |
| tree | 6f6f4ce640989a4f78d8f3ca7d1b39b9ac10ceef /src/hash | |
| parent | 7ebefd22e79e92542d68743af933c1a188f4d5a3 (diff) | |
| download | libgit2-a8527429dc48ce0f9b63789715ed8eaa9b1abf0d.tar.gz | |
unload dll / destroy hash ctxs at shutdown
Diffstat (limited to 'src/hash')
| -rw-r--r-- | src/hash/hash_generic.h | 1 | ||||
| -rw-r--r-- | src/hash/hash_openssl.h | 1 | ||||
| -rw-r--r-- | src/hash/hash_ppc.h | 1 | ||||
| -rw-r--r-- | src/hash/hash_win32.c | 25 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/hash/hash_generic.h b/src/hash/hash_generic.h index 92c9cb9ca..7c4be7873 100644 --- a/src/hash/hash_generic.h +++ b/src/hash/hash_generic.h @@ -17,6 +17,7 @@ struct git_hash_ctx { }; #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_cleanup(ctx) diff --git a/src/hash/hash_openssl.h b/src/hash/hash_openssl.h index 39c47aece..3ae49a732 100644 --- a/src/hash/hash_openssl.h +++ b/src/hash/hash_openssl.h @@ -17,6 +17,7 @@ struct git_hash_ctx { }; #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_cleanup(ctx) diff --git a/src/hash/hash_ppc.h b/src/hash/hash_ppc.h index df6570e22..935f73f7f 100644 --- a/src/hash/hash_ppc.h +++ b/src/hash/hash_ppc.h @@ -21,6 +21,7 @@ struct git_hash_ctx { }; #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_cleanup(ctx) diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c index c49094295..a89dffa7c 100644 --- a/src/hash/hash_win32.c +++ b/src/hash/hash_win32.c @@ -26,6 +26,8 @@ GIT_INLINE(int) hash_cng_prov_init(void) char dll_path[MAX_PATH]; DWORD dll_path_len, size_len; + return -1; + /* Only use CNG on Windows 2008 / Vista SP1 or better (Windows 6.0 SP1) */ version_test.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); version_test.dwMajorVersion = 6; @@ -79,6 +81,14 @@ GIT_INLINE(int) hash_cng_prov_init(void) 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 */ GIT_INLINE(int) hash_cryptoapi_prov_init() { @@ -89,6 +99,13 @@ GIT_INLINE(int) hash_cryptoapi_prov_init() 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 error = 0; @@ -102,6 +119,14 @@ int git_hash_global_init() 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 */ GIT_INLINE(int) hash_ctx_cryptoapi_init(git_hash_ctx *ctx) |
