mirror of
https://github.com/libp2p/go-openssl.git
synced 2025-01-16 02:50:26 +08:00
Set thread id callback as required by openssl.
This commit is contained in:
parent
85c7f475b6
commit
6ac1e9e6b9
@ -60,5 +60,13 @@ void go_thread_locking_callback(int mode, int n, const char *file,
|
|||||||
pthread_mutex_unlock(&goopenssl_locks[n]);
|
pthread_mutex_unlock(&goopenssl_locks[n]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned long go_thread_id_callback(void)
|
||||||
|
{
|
||||||
|
unsigned long ret;
|
||||||
|
|
||||||
|
ret = (unsigned long)pthread_self();
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
6
shim.c
6
shim.c
@ -33,6 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
extern int go_init_locks();
|
extern int go_init_locks();
|
||||||
extern void go_thread_locking_callback(int, int, const char*, int);
|
extern void go_thread_locking_callback(int, int, const char*, int);
|
||||||
|
extern unsigned long go_thread_id_callback();
|
||||||
static int go_write_bio_puts(BIO *b, const char *str) {
|
static int go_write_bio_puts(BIO *b, const char *str) {
|
||||||
return go_write_bio_write(b, (char*)str, (int)strlen(str));
|
return go_write_bio_write(b, (char*)str, (int)strlen(str));
|
||||||
}
|
}
|
||||||
@ -325,14 +326,13 @@ int X_shim_init() {
|
|||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
OpenSSL_add_all_algorithms();
|
OpenSSL_add_all_algorithms();
|
||||||
//
|
//
|
||||||
// Set up OPENSSL thread safety callbacks. We only set the locking
|
// Set up OPENSSL thread safety callbacks.
|
||||||
// callback because the default id callback implementation is good
|
|
||||||
// enough for us.
|
|
||||||
rc = go_init_locks();
|
rc = go_init_locks();
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
CRYPTO_set_locking_callback(go_thread_locking_callback);
|
CRYPTO_set_locking_callback(go_thread_locking_callback);
|
||||||
|
CRYPTO_set_id_callback(go_thread_id_callback)
|
||||||
|
|
||||||
rc = x_bio_init_methods();
|
rc = x_bio_init_methods();
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user