aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-28 05:40:54 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-28 05:40:54 +0000
commit835d24f637e7616787e369ae4bf7edd0f8302a3d (patch)
tree90d03e4c06444805b44e67b306d7c2b7ad7551fe
parent8111b32d685278de68e9eefe273524cf1266cff0 (diff)
downloadruby-835d24f637e7616787e369ae4bf7edd0f8302a3d.tar.gz
* thread.c (rb_mutex_lock): moved trap context check from
rb_mutex_trylock because try_lock have no change to make a deadlock. * thread.c (rb_mutex_trylock): ditto. * NEWS: news for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--thread.c12
2 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b6926cae01..ea350e1fc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Nov 28 14:34:06 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
+
+ * thread.c (rb_mutex_lock): moved trap context check from
+ rb_mutex_trylock because try_lock have no change to make
+ a deadlock.
+ * thread.c (rb_mutex_trylock): ditto.
+ * NEWS: news for the above.
+
Wed Nov 28 13:39:54 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* thread.c (thread_s_new): uses main_thread->status instead of
diff --git a/thread.c b/thread.c
index b57e539444..97ab79f93e 100644
--- a/thread.c
+++ b/thread.c
@@ -4060,11 +4060,6 @@ rb_mutex_trylock(VALUE self)
VALUE locked = Qfalse;
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);
if (mutex->th == 0) {
mutex->th = GET_THREAD();
@@ -4144,10 +4139,15 @@ static const rb_thread_t *patrol_thread = NULL;
VALUE
rb_mutex_lock(VALUE self)
{
+ rb_thread_t *th = GET_THREAD();
+
+ /* When running trap handler */
+ if (th->interrupt_mask & TRAP_INTERRUPT_MASK) {
+ rb_raise(rb_eThreadError, "can't be called from trap context");
+ }
if (rb_mutex_trylock(self) == Qfalse) {
rb_mutex_t *mutex;
- rb_thread_t *th = GET_THREAD();
GetMutexPtr(self, mutex);
if (mutex->th == GET_THREAD()) {