mirror of
https://github.com/corda/corda.git
synced 2025-01-23 04:48:09 +00:00
ignore DetachCurrentThread calls for the main thread
My earlier commit to allow detaching the main thread (1f1c3c4
) seems
to have caused subtle stability problems
(e.g. https://groups.google.com/group/avian/msg/d2c797c0dcf925c3), so
for now we'll just ignore that operation, which leaks a bit of memory
but should be harmless otherwise.
This commit is contained in:
parent
d3b32ecffd
commit
eee2ce27e4
@ -45,17 +45,23 @@ DetachCurrentThread(Machine* m)
|
|||||||
{
|
{
|
||||||
Thread* t = static_cast<Thread*>(m->localThread->get());
|
Thread* t = static_cast<Thread*>(m->localThread->get());
|
||||||
if (t) {
|
if (t) {
|
||||||
m->localThread->set(0);
|
// todo: detaching the root thread seems to cause stability
|
||||||
|
// problems which I haven't yet had a chance to investigate
|
||||||
|
// thoroughly. Meanwhile, we just ignore requests to detach it,
|
||||||
|
// which leaks a bit of memory but should be harmless otherwise.
|
||||||
|
if (m->rootThread != t) {
|
||||||
|
m->localThread->set(0);
|
||||||
|
|
||||||
ACQUIRE_RAW(t, t->m->stateLock);
|
ACQUIRE_RAW(t, t->m->stateLock);
|
||||||
|
|
||||||
enter(t, Thread::ActiveState);
|
enter(t, Thread::ActiveState);
|
||||||
|
|
||||||
threadPeer(t, t->javaThread) = 0;
|
threadPeer(t, t->javaThread) = 0;
|
||||||
|
|
||||||
enter(t, Thread::ZombieState);
|
enter(t, Thread::ZombieState);
|
||||||
|
|
||||||
t->state = Thread::JoinedState;
|
t->state = Thread::JoinedState;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user