116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
* Threaded operation requires locking callbacks
* Based from /crypto/cryptlib.c of OpenSSL and NSOpenSSL.
*/
static Tcl_Mutex *locks = NULL;
static Tcl_Mutex init_mx;
static void CryptoThreadLockCallback(int mode, int n, const char *file, int line);
static unsigned long CryptoThreadIdCallback(void);
static void CryptoThreadLockCallback(int mode, int n, const char *file, int line) {
if (mode & CRYPTO_LOCK) {
Tcl_MutexLock(&locks[n]);
} else {
Tcl_MutexUnlock(&locks[n]);
}
}
static unsigned long CryptoThreadIdCallback(void) {
return (unsigned long) Tcl_GetCurrentThread();
}
#endif /* OPENSSL_THREADS */
#endif /* TCL_THREADS */
/*
|
<
<
<
|
|
|
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
* Threaded operation requires locking callbacks
* Based from /crypto/cryptlib.c of OpenSSL and NSOpenSSL.
*/
static Tcl_Mutex *locks = NULL;
static Tcl_Mutex init_mx;
void CryptoThreadLockCallback(int mode, int n, const char *file, int line) {
if (mode & CRYPTO_LOCK) {
Tcl_MutexLock(&locks[n]);
} else {
Tcl_MutexUnlock(&locks[n]);
}
}
unsigned long CryptoThreadIdCallback(void) {
return (unsigned long) Tcl_GetCurrentThread();
}
#endif /* OPENSSL_THREADS */
#endif /* TCL_THREADS */
/*
|
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
|
if (!initialized) {
dprintf("Asked to uninitialize, but we are not initialized");
return(TCL_OK);
}
dprintf("Asked to uninitialize");
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
Tcl_MutexLock(&init_mx);
CRYPTO_set_locking_callback(NULL);
CRYPTO_set_id_callback(NULL);
if (locks) {
|
>
|
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
|
if (!initialized) {
dprintf("Asked to uninitialize, but we are not initialized");
return(TCL_OK);
}
dprintf("Asked to uninitialize");
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
Tcl_MutexLock(&init_mx);
CRYPTO_set_locking_callback(NULL);
CRYPTO_set_id_callback(NULL);
if (locks) {
|
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
|
return(TCL_OK);
}
if (initialized) {
return(status);
}
initialized = 1;
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
Tcl_MutexLock(&init_mx);
num_locks = CRYPTO_num_locks();
locks = malloc(sizeof(*locks) * num_locks);
CRYPTO_set_locking_callback(CryptoThreadLockCallback);
CRYPTO_set_id_callback(CryptoThreadIdCallback);
#endif
|
>
>
>
<
<
|
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
|
return(TCL_OK);
}
if (initialized) {
return(status);
}
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
Tcl_MutexLock(&init_mx);
#endif
initialized = 1;
#if defined(OPENSSL_THREADS) && defined(TCL_THREADS)
num_locks = CRYPTO_num_locks();
locks = malloc(sizeof(*locks) * num_locks);
CRYPTO_set_locking_callback(CryptoThreadLockCallback);
CRYPTO_set_id_callback(CryptoThreadIdCallback);
#endif
|