Convert ASYNC code to use new Thread API
The async code uses thread local variables. We should convert to using the new Thread API for doing this. Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
@@ -58,38 +58,9 @@
|
||||
# include <windows.h>
|
||||
# include "internal/cryptlib.h"
|
||||
|
||||
struct winpool {
|
||||
STACK_OF(ASYNC_JOB) *pool;
|
||||
size_t curr_size;
|
||||
size_t max_size;
|
||||
};
|
||||
|
||||
static DWORD asyncwinpool = 0;
|
||||
static DWORD asyncwinctx = 0;
|
||||
|
||||
|
||||
void async_start_func(void);
|
||||
|
||||
int async_global_init(void)
|
||||
{
|
||||
asyncwinpool = TlsAlloc();
|
||||
asyncwinctx = TlsAlloc();
|
||||
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);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void async_local_cleanup(void)
|
||||
{
|
||||
async_ctx *ctx = async_arch_get_ctx();
|
||||
async_ctx *ctx = async_get_ctx();
|
||||
if (ctx != NULL) {
|
||||
async_fibre *fibre = &ctx->dispatcher;
|
||||
if(fibre != NULL && fibre->fibre != NULL && fibre->converted) {
|
||||
@@ -99,14 +70,6 @@ void async_local_cleanup(void)
|
||||
}
|
||||
}
|
||||
|
||||
void async_global_cleanup(void)
|
||||
{
|
||||
TlsFree(asyncwinpool);
|
||||
TlsFree(asyncwinctx);
|
||||
asyncwinpool = 0;
|
||||
asyncwinctx = 0;
|
||||
}
|
||||
|
||||
int async_fibre_init_dispatcher(async_fibre *fibre)
|
||||
{
|
||||
fibre->fibre = ConvertThreadToFiber(NULL);
|
||||
@@ -127,25 +90,4 @@ VOID CALLBACK async_start_func_win(PVOID unused)
|
||||
async_start_func();
|
||||
}
|
||||
|
||||
async_pool *async_get_pool(void)
|
||||
{
|
||||
return (async_pool *)TlsGetValue(asyncwinpool);
|
||||
}
|
||||
|
||||
|
||||
int async_set_pool(async_pool *pool)
|
||||
{
|
||||
return TlsSetValue(asyncwinpool, (LPVOID)pool) != 0;
|
||||
}
|
||||
|
||||
async_ctx *async_arch_get_ctx(void)
|
||||
{
|
||||
return (async_ctx *)TlsGetValue(asyncwinctx);
|
||||
}
|
||||
|
||||
int async_set_ctx(async_ctx *ctx)
|
||||
{
|
||||
return TlsSetValue(asyncwinctx, (LPVOID)ctx) != 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user