diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | thread.c | 28 | ||||
-rw-r--r-- | version.h | 6 |
3 files changed, 27 insertions, 13 deletions
@@ -1,3 +1,9 @@ +Fri Jan 11 01:08:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org> + + * 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@ruby-lang.org> * prelude.rb (Mutex::synchronize): capture exception from unlock. @@ -2362,22 +2362,30 @@ VALUE 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); - mutex->th = 0; - if (mutex->cond_waiting > 0) { - /* waiting thread */ - native_cond_signal(&mutex->cond); - mutex->cond_waiting--; + + 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_unlock(&mutex->lock); + if (err) rb_raise(rb_eThreadError, err); + return self; } @@ -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[]; |