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

ruby-changes:25865

From: kosaki <ko1@a...>
Date: Wed, 28 Nov 2012 14:41:04 +0900 (JST)
Subject: [ruby-changes:25865] kosaki:r37922 (trunk): * thread.c (rb_mutex_lock): moved trap context check from

kosaki	2012-11-28 14:40:54 +0900 (Wed, 28 Nov 2012)

  New Revision: 37922

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

  Log:
    * thread.c (rb_mutex_lock): moved trap context check from
      rb_mutex_trylock because try_lock have no change to make
      a deadlock.
    * thread.c (rb_mutex_trylock): ditto.
    * NEWS: news for the above.

  Modified files:
    trunk/ChangeLog
    trunk/thread.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 37921)
+++ ChangeLog	(revision 37922)
@@ -1,3 +1,11 @@
+Wed Nov 28 14:34:06 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* thread.c (rb_mutex_lock): moved trap context check from
+	  rb_mutex_trylock because try_lock have no change to make
+	  a deadlock.
+	* thread.c (rb_mutex_trylock): ditto.
+	* NEWS: news for the above.
+
 Wed Nov 28 13:39:54 2012  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread.c (thread_s_new): uses main_thread->status instead of
Index: thread.c
===================================================================
--- thread.c	(revision 37921)
+++ thread.c	(revision 37922)
@@ -4060,11 +4060,6 @@
     VALUE locked = Qfalse;
     GetMutexPtr(self, mutex);
 
-    /* When running trap handler */
-    if (GET_THREAD()->interrupt_mask & TRAP_INTERRUPT_MASK) {
-	rb_raise(rb_eThreadError, "can't be called from trap context");
-    }
-
     native_mutex_lock(&mutex->lock);
     if (mutex->th == 0) {
 	mutex->th = GET_THREAD();
@@ -4144,10 +4139,15 @@
 VALUE
 rb_mutex_lock(VALUE self)
 {
+    rb_thread_t *th = GET_THREAD();
 
+    /* When running trap handler */
+    if (th->interrupt_mask & TRAP_INTERRUPT_MASK) {
+	rb_raise(rb_eThreadError, "can't be called from trap context");
+    }
+
     if (rb_mutex_trylock(self) == Qfalse) {
 	rb_mutex_t *mutex;
-	rb_thread_t *th = GET_THREAD();
 	GetMutexPtr(self, mutex);
 
 	if (mutex->th == GET_THREAD()) {

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

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