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

ruby-changes:3487

From: ko1@a...
Date: 11 Jan 2008 01:12:52 +0900
Subject: [ruby-changes:3487] matz - Ruby:r14980 (trunk): * thread.c (rb_mutex_unlock): proper error message for unlocking

matz	2008-01-11 01:12:32 +0900 (Fri, 11 Jan 2008)

  New Revision: 14980

  Modified files:
    trunk/ChangeLog
    trunk/thread.c
    trunk/version.h

  Log:
    * thread.c (rb_mutex_unlock): proper error message for unlocking
      mutex that is not locked.  a patch from Yusuke ENDOH
      <mame at tsg.ne.jp> in [ruby-dev:33010].

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=14980&r2=14979&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14980&r2=14979&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=14980&r2=14979&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14979)
+++ ChangeLog	(revision 14980)
@@ -1,3 +1,9 @@
+Fri Jan 11 01:08:01 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* thread.c (rb_mutex_unlock): proper error message for unlocking
+	  mutex that is not locked.  a patch from Yusuke ENDOH
+	  <mame at tsg.ne.jp> in [ruby-dev:33010].
+
 Thu Jan 10 18:00:41 2008  Yukihiro Matsumoto  <matz@r...>
 
 	* prelude.rb (Mutex::synchronize): capture exception from unlock.
Index: thread.c
===================================================================
--- thread.c	(revision 14979)
+++ thread.c	(revision 14980)
@@ -2362,22 +2362,30 @@
 rb_mutex_unlock(VALUE self)
 {
     mutex_t *mutex;
+    char *err = NULL;
     GetMutexPtr(self, mutex);
 
-    if (mutex->th != GET_THREAD()) {
-	rb_raise(rb_eThreadError,
-		 "Attempt to unlock a mutex which is locked by another thread");
+    native_mutex_lock(&mutex->lock);
+
+    if (mutex->th == 0) {
+	err = "Attempt to unlock a mutex which is not locked";
     }
+    else if (mutex->th != GET_THREAD()) {
+	err = "Attempt to unlock a mutex which is locked by another thread";
+    }
+    else {
+	mutex->th = 0;
+	if (mutex->cond_waiting > 0) {
+	    /* waiting thread */
+	    native_cond_signal(&mutex->cond);
+	    mutex->cond_waiting--;
+	}
+    }
 
-    native_mutex_lock(&mutex->lock);
-    mutex->th = 0;
-    if (mutex->cond_waiting > 0) {
-	/* waiting thread */
-	native_cond_signal(&mutex->cond);
-	mutex->cond_waiting--;
-    }
     native_mutex_unlock(&mutex->lock);
 
+    if (err) rb_raise(rb_eThreadError, err);
+
     return self;
 }
 
Index: version.h
===================================================================
--- version.h	(revision 14979)
+++ version.h	(revision 14980)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-01-10"
+#define RUBY_RELEASE_DATE "2008-01-11"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080110
+#define RUBY_RELEASE_CODE 20080111
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 10
+#define RUBY_RELEASE_DAY 11
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];

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

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