* 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:
parent
7a360de149
commit
d17bcfc802
@ -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>
|
Thu Jan 10 18:00:41 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* prelude.rb (Mutex::synchronize): capture exception from unlock.
|
* prelude.rb (Mutex::synchronize): capture exception from unlock.
|
||||||
|
28
thread.c
28
thread.c
@ -2362,22 +2362,30 @@ VALUE
|
|||||||
rb_mutex_unlock(VALUE self)
|
rb_mutex_unlock(VALUE self)
|
||||||
{
|
{
|
||||||
mutex_t *mutex;
|
mutex_t *mutex;
|
||||||
|
char *err = NULL;
|
||||||
GetMutexPtr(self, mutex);
|
GetMutexPtr(self, mutex);
|
||||||
|
|
||||||
if (mutex->th != GET_THREAD()) {
|
native_mutex_lock(&mutex->lock);
|
||||||
rb_raise(rb_eThreadError,
|
|
||||||
"Attempt to unlock a mutex which is locked by another thread");
|
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);
|
native_mutex_unlock(&mutex->lock);
|
||||||
|
|
||||||
|
if (err) rb_raise(rb_eThreadError, err);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#define RUBY_VERSION "1.9.0"
|
#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_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20080110
|
#define RUBY_RELEASE_CODE 20080111
|
||||||
#define RUBY_PATCHLEVEL 0
|
#define RUBY_PATCHLEVEL 0
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#define RUBY_VERSION_TEENY 0
|
#define RUBY_VERSION_TEENY 0
|
||||||
#define RUBY_RELEASE_YEAR 2008
|
#define RUBY_RELEASE_YEAR 2008
|
||||||
#define RUBY_RELEASE_MONTH 1
|
#define RUBY_RELEASE_MONTH 1
|
||||||
#define RUBY_RELEASE_DAY 10
|
#define RUBY_RELEASE_DAY 11
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user