1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-01-10 16:12:32 +00:00
parent 7a360de149
commit d17bcfc802
3 changed files with 27 additions and 13 deletions

View file

@ -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.

View file

@ -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);
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;
}

View file

@ -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[];