mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (rb_mutex_trylock, rb_mutex_unlock, mutex_sleep):
raises ThreadError if called from trap handler as Thread#join. * NEWS: news fot the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
23d5c282b4
commit
5b238e8dc7
3 changed files with 31 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Nov 27 00:13:41 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
|
* thread.c (rb_mutex_trylock, rb_mutex_unlock, mutex_sleep):
|
||||||
|
raises ThreadError if called from trap handler as Thread#join.
|
||||||
|
* NEWS: news fot the above.
|
||||||
|
|
||||||
Mon Nov 26 23:55:33 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Mon Nov 26 23:55:33 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* NEWS: update for Thread#join incompatible change.
|
* NEWS: update for Thread#join incompatible change.
|
||||||
|
|
10
NEWS
10
NEWS
|
@ -105,6 +105,12 @@ with all sufficient information, see the ChangeLog file.
|
||||||
* Module#const_get accepts a qualified constant string, e.g.
|
* Module#const_get accepts a qualified constant string, e.g.
|
||||||
Object.const_get("Foo::Bar::Baz")
|
Object.const_get("Foo::Bar::Baz")
|
||||||
|
|
||||||
|
* Mutex
|
||||||
|
* incompatible changes:
|
||||||
|
* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize
|
||||||
|
and Mutex#sleep no longer allows to be used from trap handler.
|
||||||
|
Now it raises ThreadError.
|
||||||
|
|
||||||
* NilClass
|
* NilClass
|
||||||
* added method:
|
* added method:
|
||||||
* added nil.to_h which returns {}
|
* added nil.to_h which returns {}
|
||||||
|
@ -350,3 +356,7 @@ with all sufficient information, see the ChangeLog file.
|
||||||
* Thread#join
|
* Thread#join
|
||||||
|
|
||||||
See above.
|
See above.
|
||||||
|
|
||||||
|
* Mutex#lock, Mutex#unlock, Mutex#try_lock, Mutex#synchronize and Mutex#sleep
|
||||||
|
|
||||||
|
See above.
|
||||||
|
|
15
thread.c
15
thread.c
|
@ -4051,6 +4051,11 @@ rb_mutex_trylock(VALUE self)
|
||||||
VALUE locked = Qfalse;
|
VALUE locked = Qfalse;
|
||||||
GetMutexPtr(self, mutex);
|
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);
|
native_mutex_lock(&mutex->lock);
|
||||||
if (mutex->th == 0) {
|
if (mutex->th == 0) {
|
||||||
mutex->th = GET_THREAD();
|
mutex->th = GET_THREAD();
|
||||||
|
@ -4239,6 +4244,11 @@ rb_mutex_unlock(VALUE self)
|
||||||
rb_mutex_t *mutex;
|
rb_mutex_t *mutex;
|
||||||
GetMutexPtr(self, mutex);
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
err = rb_mutex_unlock_th(mutex, GET_THREAD());
|
err = rb_mutex_unlock_th(mutex, GET_THREAD());
|
||||||
if (err) rb_raise(rb_eThreadError, "%s", err);
|
if (err) rb_raise(rb_eThreadError, "%s", err);
|
||||||
|
|
||||||
|
@ -4307,6 +4317,11 @@ mutex_sleep(int argc, VALUE *argv, VALUE self)
|
||||||
{
|
{
|
||||||
VALUE timeout;
|
VALUE timeout;
|
||||||
|
|
||||||
|
/* When running trap handler */
|
||||||
|
if (GET_THREAD()->interrupt_mask & TRAP_INTERRUPT_MASK) {
|
||||||
|
rb_raise(rb_eThreadError, "can't be called from trap context");
|
||||||
|
}
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", &timeout);
|
rb_scan_args(argc, argv, "01", &timeout);
|
||||||
return rb_mutex_sleep(self, timeout);
|
return rb_mutex_sleep(self, timeout);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue