2015-02-17 13:30:22 +00:00
|
|
|
/*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-02-17 13:30:22 +00:00
|
|
|
*
|
2016-05-17 18:24:46 +00:00
|
|
|
* Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
|
|
* in the file LICENSE in the source distribution or at
|
|
|
|
* https://www.openssl.org/source/license.html
|
2015-02-17 13:30:22 +00:00
|
|
|
*/
|
|
|
|
|
2015-11-22 01:14:43 +00:00
|
|
|
/* This must be the first #include file */
|
2015-11-13 15:21:20 +00:00
|
|
|
#include "../async_locl.h"
|
2015-02-17 13:30:22 +00:00
|
|
|
|
|
|
|
#ifdef ASYNC_WIN
|
|
|
|
|
|
|
|
# include <windows.h>
|
2015-09-16 22:43:45 +00:00
|
|
|
# include "internal/cryptlib.h"
|
|
|
|
|
2016-03-07 16:55:39 +00:00
|
|
|
int ASYNC_is_capable(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-11-19 21:44:13 +00:00
|
|
|
void async_local_cleanup(void)
|
|
|
|
{
|
2016-03-02 16:15:52 +00:00
|
|
|
async_ctx *ctx = async_get_ctx();
|
2015-11-19 21:44:13 +00:00
|
|
|
if (ctx != NULL) {
|
|
|
|
async_fibre *fibre = &ctx->dispatcher;
|
2016-06-28 22:18:50 +00:00
|
|
|
if (fibre != NULL && fibre->fibre != NULL && fibre->converted) {
|
2015-11-19 21:44:13 +00:00
|
|
|
ConvertFiberToThread();
|
|
|
|
fibre->fibre = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:25:16 +00:00
|
|
|
int async_fibre_init_dispatcher(async_fibre *fibre)
|
2015-02-17 13:30:22 +00:00
|
|
|
{
|
2016-02-08 16:43:03 +00:00
|
|
|
fibre->fibre = ConvertThreadToFiber(NULL);
|
|
|
|
if (fibre->fibre == NULL) {
|
|
|
|
fibre->converted = 0;
|
|
|
|
fibre->fibre = GetCurrentFiber();
|
|
|
|
if (fibre->fibre == NULL)
|
2015-11-19 21:44:13 +00:00
|
|
|
return 0;
|
2015-02-17 13:30:22 +00:00
|
|
|
} else {
|
2016-02-08 16:43:03 +00:00
|
|
|
fibre->converted = 1;
|
2015-02-17 13:30:22 +00:00
|
|
|
}
|
2016-02-08 16:43:03 +00:00
|
|
|
|
2015-02-17 13:30:22 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:25:16 +00:00
|
|
|
VOID CALLBACK async_start_func_win(PVOID unused)
|
2015-02-17 13:30:22 +00:00
|
|
|
{
|
2015-10-06 10:25:16 +00:00
|
|
|
async_start_func();
|
2015-02-17 13:30:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|