aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-23 09:59:28 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-23 09:59:28 +0000
commit55201cac9ea35420ef63880323d75f603374413e (patch)
treeba055a358952f2b71420a6f3eb196f2a5174b653 /ext/openssl/ossl.c
parentdb22d280e1b3a158daf825b5e189400419c33f29 (diff)
downloadruby-55201cac9ea35420ef63880323d75f603374413e.tar.gz
* ext/openssl/ossl.c: use system native (system provided)
thread locking APIs added by last commit. This patch fixes [Bug #8386]. "rb_mutex_*" APIs control only "Ruby" threads. Not for native threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl.c')
-rw-r--r--ext/openssl/ossl.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index f213f3c4cd..6032d916d8 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -461,14 +461,15 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
/**
* Stores locks needed for OpenSSL thread safety
*/
-static VALUE* ossl_locks;
+#include "../../thread_native.h"
+static rb_nativethread_lock_t *ossl_locks;
static void ossl_lock_callback(int mode, int type, const char *file, int line)
{
if (mode & CRYPTO_LOCK) {
- rb_mutex_lock(ossl_locks[type]);
+ rb_nativethread_lock_lock(&ossl_locks[type]);
} else {
- rb_mutex_unlock(ossl_locks[type]);
+ rb_nativethread_lock_unlock(&ossl_locks[type]);
}
}
@@ -485,13 +486,12 @@ static void Init_ossl_locks(void)
if ((unsigned)num_locks >= INT_MAX / (int)sizeof(VALUE)) {
rb_raise(rb_eRuntimeError, "CRYPTO_num_locks() is too big: %d", num_locks);
}
- ossl_locks = (VALUE*) OPENSSL_malloc(num_locks * (int)sizeof(VALUE));
+ ossl_locks = (rb_nativethread_lock_t *) OPENSSL_malloc(num_locks * sizeof(rb_nativethread_lock_t));
if (!ossl_locks) {
rb_raise(rb_eNoMemError, "CRYPTO_num_locks() is too big: %d", num_locks);
}
for (i = 0; i < num_locks; i++) {
- ossl_locks[i] = rb_mutex_new();
- rb_gc_register_mark_object(ossl_locks[i]);
+ rb_nativethread_lock_initialize(&ossl_locks[i]);
}
CRYPTO_set_id_callback(ossl_thread_id);