diff options
author | Matt Caswell <matt@openssl.org> | 2016-02-08 16:43:03 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-02-09 15:11:38 +0000 |
commit | 7b9f8f7f03eda2faa1cdd42ed29a0b70e60eaf59 (patch) | |
tree | 30f805756265bd1d016aead84dcf1c909cca8b4b /crypto/async/arch/async_win.c | |
parent | b184e3ef73200cb3b7914a603b43a5b8a074c85f (diff) |
Auto init/deinit libcrypto
This builds on the previous commit to auto initialise/deinitialise
libcrypto.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/async/arch/async_win.c')
-rw-r--r-- | crypto/async/arch/async_win.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/crypto/async/arch/async_win.c b/crypto/async/arch/async_win.c index f3de79a73b..3f3a005cc2 100644 --- a/crypto/async/arch/async_win.c +++ b/crypto/async/arch/async_win.c @@ -66,7 +66,6 @@ struct winpool { static DWORD asyncwinpool = 0; static DWORD asyncwinctx = 0; -static DWORD asyncwindispatch = 0; void async_start_func(void); @@ -75,33 +74,22 @@ int async_global_init(void) { asyncwinpool = TlsAlloc(); asyncwinctx = TlsAlloc(); - asyncwindispatch = TlsAlloc(); - if (asyncwinpool == TLS_OUT_OF_INDEXES || asyncwinctx == TLS_OUT_OF_INDEXES - || asyncwindispatch == TLS_OUT_OF_INDEXES) { + if (asyncwinpool == TLS_OUT_OF_INDEXES + || asyncwinctx == TLS_OUT_OF_INDEXES) { if (asyncwinpool != TLS_OUT_OF_INDEXES) { TlsFree(asyncwinpool); } if (asyncwinctx != TLS_OUT_OF_INDEXES) { TlsFree(asyncwinctx); } - if (asyncwindispatch != TLS_OUT_OF_INDEXES) { - TlsFree(asyncwindispatch); - } return 0; } return 1; } -int async_local_init(void) -{ - return (TlsSetValue(asyncwinpool, NULL) != 0) - && (TlsSetValue(asyncwinctx, NULL) != 0) - && (TlsSetValue(asyncwindispatch, NULL) != 0); -} - void async_local_cleanup(void) { - async_ctx *ctx = async_get_ctx(); + async_ctx *ctx = async_arch_get_ctx(); if (ctx != NULL) { async_fibre *fibre = &ctx->dispatcher; if(fibre != NULL && fibre->fibre != NULL && fibre->converted) { @@ -115,32 +103,24 @@ void async_global_cleanup(void) { TlsFree(asyncwinpool); TlsFree(asyncwinctx); - TlsFree(asyncwindispatch); asyncwinpool = 0; asyncwinctx = 0; - asyncwindispatch = 0; } int async_fibre_init_dispatcher(async_fibre *fibre) { LPVOID dispatcher; - dispatcher = (LPVOID)TlsGetValue(asyncwindispatch); - if (dispatcher == NULL) { - fibre->fibre = ConvertThreadToFiber(NULL); - if (fibre->fibre == NULL) { - fibre->converted = 0; - fibre->fibre = GetCurrentFiber(); - if (fibre->fibre == NULL) - return 0; - } else { - fibre->converted = 1; - } - if (TlsSetValue(asyncwindispatch, (LPVOID)fibre->fibre) == 0) + fibre->fibre = ConvertThreadToFiber(NULL); + if (fibre->fibre == NULL) { + fibre->converted = 0; + fibre->fibre = GetCurrentFiber(); + if (fibre->fibre == NULL) return 0; } else { - fibre->fibre = dispatcher; + fibre->converted = 1; } + return 1; } @@ -196,7 +176,7 @@ int async_set_pool(async_pool *pool) return TlsSetValue(asyncwinpool, (LPVOID)pool) != 0; } -async_ctx *async_get_ctx(void) +async_ctx *async_arch_get_ctx(void) { return (async_ctx *)TlsGetValue(asyncwinctx); } |