[前][次][番号順一覧][スレッド一覧]

ruby-changes:30083

From: ko1 <ko1@a...>
Date: Tue, 23 Jul 2013 18:59:38 +0900 (JST)
Subject: [ruby-changes:30083] ko1:r42135 (trunk): * ext/openssl/ossl.c: use system native (system provided)

ko1	2013-07-23 18:59:28 +0900 (Tue, 23 Jul 2013)

  New Revision: 42135

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42135

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/ossl.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42134)
+++ ChangeLog	(revision 42135)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jul 23 18:56:11 2013  Koichi Sasada  <ko1@a...>
+
+	* 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.
+
 Tue Jul 23 18:44:15 2013  Koichi Sasada  <ko1@a...>
 
 	* thread_native.h: added.
Index: ext/openssl/ossl.c
===================================================================
--- ext/openssl/ossl.c	(revision 42134)
+++ ext/openssl/ossl.c	(revision 42135)
@@ -461,14 +461,15 @@ ossl_fips_mode_set(VALUE self, VALUE ena https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L461
 /**
  * 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) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl.c#L486
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]