mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/openssl/ossl.c: support additional three thread synchronization
functions. [ruby-trunk - Bug #8386] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
03b6602417
commit
dda113e3ff
2 changed files with 43 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Jul 25 12:32:11 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* ext/openssl/ossl.c: support additional three thread synchronization
|
||||||
|
functions. [ruby-trunk - Bug #8386]
|
||||||
|
|
||||||
Thu Jul 25 07:15:58 2013 Eric Hodel <drbrain@segment7.net>
|
Thu Jul 25 07:15:58 2013 Eric Hodel <drbrain@segment7.net>
|
||||||
|
|
||||||
* lib/rubygems: Import RubyGems from master as of commit 4ff70cc
|
* lib/rubygems: Import RubyGems from master as of commit 4ff70cc
|
||||||
|
|
|
@ -464,15 +464,47 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
|
||||||
#include "../../thread_native.h"
|
#include "../../thread_native.h"
|
||||||
static rb_nativethread_lock_t *ossl_locks;
|
static rb_nativethread_lock_t *ossl_locks;
|
||||||
|
|
||||||
static void ossl_lock_callback(int mode, int type, const char *file, int line)
|
static void
|
||||||
|
ossl_lock_unlock(int mode, rb_nativethread_lock_t *lock)
|
||||||
{
|
{
|
||||||
if (mode & CRYPTO_LOCK) {
|
if (mode & CRYPTO_LOCK) {
|
||||||
rb_nativethread_lock_lock(&ossl_locks[type]);
|
rb_nativethread_lock_lock(lock);
|
||||||
} else {
|
} else {
|
||||||
rb_nativethread_lock_unlock(&ossl_locks[type]);
|
rb_nativethread_lock_unlock(lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossl_lock_callback(int mode, int type, const char *file, int line)
|
||||||
|
{
|
||||||
|
ossl_lock_unlock(mode, &ossl_locks[type]);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CRYPTO_dynlock_value {
|
||||||
|
rb_nativethread_lock_t lock;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct CRYPTO_dynlock_value *
|
||||||
|
ossl_dyn_create_callback(const char *file, int line)
|
||||||
|
{
|
||||||
|
struct CRYPTO_dynlock_value *dynlock = (struct CRYPTO_dynlock_value *)OPENSSL_malloc((int)sizeof(struct CRYPTO_dynlock_value));
|
||||||
|
rb_nativethread_lock_initialize(&dynlock->lock);
|
||||||
|
return dynlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossl_dyn_lock_callback(int mode, struct CRYPTO_dynlock_value *l, const char *file, int line)
|
||||||
|
{
|
||||||
|
ossl_lock_unlock(mode, &l->lock);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ossl_dyn_destroy_callback(struct CRYPTO_dynlock_value *l, const char *file, int line)
|
||||||
|
{
|
||||||
|
rb_nativethread_lock_destroy(&l->lock);
|
||||||
|
OPENSSL_free(l);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_CRYPTO_THREADID_PTR
|
#ifdef HAVE_CRYPTO_THREADID_PTR
|
||||||
static void ossl_threadid_func(CRYPTO_THREADID *id)
|
static void ossl_threadid_func(CRYPTO_THREADID *id)
|
||||||
{
|
{
|
||||||
|
@ -509,6 +541,9 @@ static void Init_ossl_locks(void)
|
||||||
CRYPTO_set_id_callback(ossl_thread_id);
|
CRYPTO_set_id_callback(ossl_thread_id);
|
||||||
#endif
|
#endif
|
||||||
CRYPTO_set_locking_callback(ossl_lock_callback);
|
CRYPTO_set_locking_callback(ossl_lock_callback);
|
||||||
|
CRYPTO_set_dynlock_create_callback(ossl_dyn_create_callback);
|
||||||
|
CRYPTO_set_dynlock_lock_callback(ossl_dyn_lock_callback);
|
||||||
|
CRYPTO_set_dynlock_destroy_callback(ossl_dyn_destroy_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue