2015-02-17 21:30:22 +08:00
|
|
|
/*
|
2016-05-18 02:24:46 +08:00
|
|
|
* Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
|
2015-02-17 21:30:22 +08:00
|
|
|
*
|
2016-05-18 02:24:46 +08: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 21:30:22 +08:00
|
|
|
*/
|
|
|
|
|
2015-11-22 09:14:43 +08:00
|
|
|
/* This must be the first #include file */
|
2015-11-13 23:21:20 +08:00
|
|
|
#include "../async_locl.h"
|
2015-02-17 21:30:22 +08:00
|
|
|
|
|
|
|
#ifdef ASYNC_WIN
|
|
|
|
|
|
|
|
# include <windows.h>
|
2015-09-17 06:43:45 +08:00
|
|
|
# include "internal/cryptlib.h"
|
|
|
|
|
2016-03-08 00:55:39 +08:00
|
|
|
int ASYNC_is_capable(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-11-20 05:44:13 +08:00
|
|
|
void async_local_cleanup(void)
|
|
|
|
{
|
2016-03-03 00:15:52 +08:00
|
|
|
async_ctx *ctx = async_get_ctx();
|
2015-11-20 05:44:13 +08:00
|
|
|
if (ctx != NULL) {
|
|
|
|
async_fibre *fibre = &ctx->dispatcher;
|
2016-06-29 06:18:50 +08:00
|
|
|
if (fibre != NULL && fibre->fibre != NULL && fibre->converted) {
|
2015-11-20 05:44:13 +08:00
|
|
|
ConvertFiberToThread();
|
|
|
|
fibre->fibre = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-06 18:25:16 +08:00
|
|
|
int async_fibre_init_dispatcher(async_fibre *fibre)
|
2015-02-17 21:30:22 +08:00
|
|
|
{
|
2016-02-09 00:43:03 +08:00
|
|
|
fibre->fibre = ConvertThreadToFiber(NULL);
|
|
|
|
if (fibre->fibre == NULL) {
|
|
|
|
fibre->converted = 0;
|
|
|
|
fibre->fibre = GetCurrentFiber();
|
|
|
|
if (fibre->fibre == NULL)
|
2015-11-20 05:44:13 +08:00
|
|
|
return 0;
|
2015-02-17 21:30:22 +08:00
|
|
|
} else {
|
2016-02-09 00:43:03 +08:00
|
|
|
fibre->converted = 1;
|
2015-02-17 21:30:22 +08:00
|
|
|
}
|
2016-02-09 00:43:03 +08:00
|
|
|
|
2015-02-17 21:30:22 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-10-06 18:25:16 +08:00
|
|
|
VOID CALLBACK async_start_func_win(PVOID unused)
|
2015-02-17 21:30:22 +08:00
|
|
|
{
|
2015-10-06 18:25:16 +08:00
|
|
|
async_start_func();
|
2015-02-17 21:30:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|