ruby-changes:39382
From: nobu <ko1@a...>
Date: Sat, 1 Aug 2015 13:48:15 +0900 (JST)
Subject: [ruby-changes:39382] nobu:r51463 (trunk): thread.c: thread_shield_get_mutex
nobu 2015-08-01 13:47:53 +0900 (Sat, 01 Aug 2015) New Revision: 51463 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51463 Log: thread.c: thread_shield_get_mutex * thread.c (thread_shield_get_mutex): explicitly check if destroyed already. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 51462) +++ thread.c (revision 51463) @@ -4713,13 +4713,22 @@ rb_thread_shield_wait(VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L4713 return rb_thread_shield_waiting(self) > 0 ? Qnil : Qfalse; } +static VALUE +thread_shield_get_mutex(VALUE self) +{ + VALUE mutex = GetThreadShieldPtr(self); + if (!mutex) + rb_raise(rb_eThreadError, "destroyed thread shield - %p", (void *)mutex); + return mutex; +} + /* * Release a thread shield, and return true if it has waiting threads. */ VALUE rb_thread_shield_release(VALUE self) { - VALUE mutex = GetThreadShieldPtr(self); + VALUE mutex = thread_shield_get_mutex(self); rb_mutex_unlock(mutex); return rb_thread_shield_waiting(self) > 0 ? Qtrue : Qfalse; } @@ -4730,7 +4739,7 @@ rb_thread_shield_release(VALUE self) https://github.com/ruby/ruby/blob/trunk/thread.c#L4739 VALUE rb_thread_shield_destroy(VALUE self) { - VALUE mutex = GetThreadShieldPtr(self); + VALUE mutex = thread_shield_get_mutex(self); DATA_PTR(self) = 0; rb_mutex_unlock(mutex); return rb_thread_shield_waiting(self) > 0 ? Qtrue : Qfalse; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/