avoid deadlock due to entering active state before running destroyJavaVM

We risked deadlock when waiting for other non-daemon threads to exit
since they could not exit without entering exclusive state, which
required waiting for all other threads to go idle.
This commit is contained in:
Joel Dice 2011-02-01 17:45:43 -07:00
parent 132f188ff0
commit 9ef9d9619d
2 changed files with 10 additions and 3 deletions

View File

@ -91,7 +91,7 @@ DestroyJavaVM(Machine* m)
{
Thread* t; AttachCurrentThread(m, &t, 0);
if (run(t, destroyJavaVM, 0)) {
if (runRaw(t, destroyJavaVM, 0)) {
t->exit();
return 0;
} else {

View File

@ -1912,12 +1912,19 @@ instanceOf(Thread* t, object class_, object o);
#include "type-declarations.cpp"
inline uint64_t
runRaw(Thread* t,
uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments)
{
Thread::RunCheckpoint checkpoint(t);
return vmRun(function, arguments, &checkpoint);
}
inline uint64_t
run(Thread* t, uint64_t (*function)(Thread*, uintptr_t*), uintptr_t* arguments)
{
ENTER(t, Thread::ActiveState);
Thread::RunCheckpoint checkpoint(t);
return vmRun(function, arguments, &checkpoint);
return runRaw(t, function, arguments);
}
inline void