summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-01 04:47:53 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-08-01 04:47:53 (GMT)
commit35a76874dbfc56c350c591efff198f3526422f18 (patch)
tree7c2e664824305a36c3f2e377e7588fada3d7e505 /thread.c
parentd8225d9f048e0df232cde5f17941b8e06d621d0b (diff)
thread.c: thread_shield_get_mutex
* thread.c (thread_shield_get_mutex): explicitly check if destroyed already. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/thread.c b/thread.c
index aaf0cd9..184fed6 100644
--- a/thread.c
+++ b/thread.c
@@ -4713,13 +4713,22 @@ rb_thread_shield_wait(VALUE self)
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)
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;