diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-12 13:01:38 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-12 13:01:38 +0000 |
commit | 6f5aaff73b2b4e17666308dde93e1ac4edb3927d (patch) | |
tree | d2045cf78eb8d6b894357491b6686fa8d23b740f /thread_pthread.c | |
parent | 2b66844f487574e2bcce1e3697883452d1f5d7fc (diff) |
* thread.c, vm_core.h, vm.c, thread_pthread.c, thread_win32.c: add
deadlock detection. [ruby-dev:35044]
* bootstraptest/test_thread.rb: add tests for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index cece65c692..54b7677146 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -402,7 +402,7 @@ ubf_select(void *ptr) #endif static void -native_sleep(rb_thread_t *th, struct timeval *tv) +native_sleep(rb_thread_t *th, struct timeval *tv, int deadlockable) { int prev_status = th->status; struct timespec ts; @@ -418,7 +418,14 @@ native_sleep(rb_thread_t *th, struct timeval *tv) } } - th->status = THREAD_STOPPED; + if (!tv && deadlockable) { + th->status = THREAD_STOPPED_FOREVER; + th->vm->sleeper++; + rb_check_deadlock(th->vm); + } + else { + th->status = THREAD_STOPPED; + } thread_debug("native_sleep %ld\n", tv ? tv->tv_sec : -1); GVL_UNLOCK_BEGIN(); @@ -455,9 +462,10 @@ native_sleep(rb_thread_t *th, struct timeval *tv) th->unblock.arg = 0; pthread_mutex_unlock(&th->interrupt_lock); - th->status = prev_status; } GVL_UNLOCK_END(); + th->status = prev_status; + if (!tv && deadlockable) th->vm->sleeper--; RUBY_VM_CHECK_INTS(); thread_debug("native_sleep done\n"); |