openssl 线程安全 Windows
来源:互联网 发布:浅情人不知网络番外 编辑:程序博客网 时间:2024/05/29 04:28
openssl 线程安全
在初始化的时候 调用 thread_setup,在结束的时候调用thread_cleanup。代码摘自crypto/threads/mttest.c
static unsigned long _stdcall thread_id(void)
{unsigned long ret;
ret=(unsigned long)GetCurrentThreadId();
return ret;
}
void thread_setup(void)
{
int i;
m_hLock_csArray = (HANDLE*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE));
for (i = 0; i < CRYPTO_num_locks(); i++) {
m_hLock_csArray[i] = CreateMutex(NULL, FALSE, NULL);
}
CRYPTO_set_locking_callback((void (*)(int, int, const char *, int))win32_locking_callback);
CRYPTO_set_id_callback((unsigned long (*)())thread_id);
}
void thread_cleanup(void)
{
int i;
CRYPTO_set_locking_callback(NULL);
for (i = 0; i < CRYPTO_num_locks(); i++)
CloseHandle(m_hLock_csArray[i]);
OPENSSL_free(m_hLock_csArray);
}
static void _stdcall win32_locking_callback(int mode, int type, const char *file, int line)
{
if (mode & CRYPTO_LOCK) {
WaitForSingleObject(m_hLock_csArray[type], INFINITE);
} else {
ReleaseMutex(m_hLock_csArray[type]);
}
}
0 0
- openssl 线程安全 Windows
- OpenSSL线程安全
- Windows窗体控件线程安全
- Windows Form线程安全调用
- Windows 窗体控件进行线程安全调用
- 使Windows Forms成为线程安全的。
- Windows下如何安全结束线程
- 跨线程安全调用Windows 窗体控件
- Windows下的PHP安装文件线程安全和非线程安全的区别
- Windows下的PHP安装文件线程安全和非线程安全的区别
- Windows下的PHP版本分两种:线程安全版本与非线程安全版本。
- windows下php线程安全与非线程安全的版本选择
- Windows下PHP线程安全版本与非线程安全版的选择
- 使用OpenSSL API安全编程
- OpenSSL曝重大安全漏
- openssl 安全套接层协议
- openssl实现文件安全传输
- 对 Windows 窗体控件进行线程安全调用
- pointwise linux ubuntu 安装 纪录
- JDBC
- hdu2037 今年暑假不AC
- 多线程安全CAS实现的无锁
- Unity3D开发基础组件提取总结
- openssl 线程安全 Windows
- 四 、Hive逻辑优化
- myeclipse的buildpath 和lib引入的区别
- UITableView增加搜素框后搜不出来内容(old)
- resteasy框架之PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy
- LeetCode-80-Remove Duplicates from Sorted Array II(递归)-Medium
- IOS自动布局之Autoresizing
- 《leetCode》:Power of Three
- Jenkins+git+fir搭建持续集成环境(超详细搭建教程)