summaryrefslogtreecommitdiffstats
path: root/thread_pthread.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-12 13:01:38 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-12 13:01:38 +0000
commit05c32b0bb62e4a56eccba0ae44a7bbef66e1858f (patch)
treed2045cf78eb8d6b894357491b6686fa8d23b740f /thread_pthread.c
parent718ca6dbaadad4bc523e050840b316306785dbad (diff)
downloadruby-05c32b0bb62e4a56eccba0ae44a7bbef66e1858f.tar.gz
ruby-05c32b0bb62e4a56eccba0ae44a7bbef66e1858f.tar.xz
ruby-05c32b0bb62e4a56eccba0ae44a7bbef66e1858f.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@17110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index cece65c69..54b767714 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");