mirror of
https://github.com/corda/corda.git
synced 2025-01-22 20:38:05 +00:00
set Thread.interrupted to true if thread is interrupted outside wait or sleep
This is the correct behavior according to the Thread.interrupt JavaDoc, and it fixes an intermittent hang on exit in Eclipse.
This commit is contained in:
parent
deeb3c694c
commit
e6afc6c321
@ -54,6 +54,12 @@ class MyClasspath : public Classpath {
|
|||||||
root(t, Machine::BootLoader), 0, 0, group, 0);
|
root(t, Machine::BootLoader), 0, 0, group, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
clearInterrupted(Thread*)
|
||||||
|
{
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
runThread(Thread* t)
|
runThread(Thread* t)
|
||||||
{
|
{
|
||||||
|
@ -344,6 +344,9 @@ makeClassNameString(Thread* t, object name)
|
|||||||
void
|
void
|
||||||
interceptFileOperations(Thread*);
|
interceptFileOperations(Thread*);
|
||||||
|
|
||||||
|
void
|
||||||
|
clearInterrupted(Thread*);
|
||||||
|
|
||||||
class MyClasspath : public Classpath {
|
class MyClasspath : public Classpath {
|
||||||
public:
|
public:
|
||||||
static const unsigned BufferSize = 1024;
|
static const unsigned BufferSize = 1024;
|
||||||
@ -506,6 +509,12 @@ class MyClasspath : public Classpath {
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
clearInterrupted(Thread* t)
|
||||||
|
{
|
||||||
|
local::clearInterrupted(t);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
runThread(Thread* t)
|
runThread(Thread* t)
|
||||||
{
|
{
|
||||||
@ -2212,6 +2221,14 @@ interruptLock(Thread* t, object thread)
|
|||||||
return threadInterruptLock(t, thread);
|
return threadInterruptLock(t, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clearInterrupted(Thread* t)
|
||||||
|
{
|
||||||
|
monitorAcquire(t, local::interruptLock(t, t->javaThread));
|
||||||
|
threadInterrupted(t, t->javaThread) = false;
|
||||||
|
monitorRelease(t, local::interruptLock(t, t->javaThread));
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pipeAvailable(int fd, int* available)
|
pipeAvailable(int fd, int* available)
|
||||||
{
|
{
|
||||||
@ -3350,9 +3367,8 @@ jvmInterrupt(Thread* t, uintptr_t* arguments)
|
|||||||
Thread* p = reinterpret_cast<Thread*>(threadPeer(t, *thread));
|
Thread* p = reinterpret_cast<Thread*>(threadPeer(t, *thread));
|
||||||
if (p) {
|
if (p) {
|
||||||
interrupt(t, p);
|
interrupt(t, p);
|
||||||
} else {
|
|
||||||
threadInterrupted(t, *thread) = true;
|
|
||||||
}
|
}
|
||||||
|
threadInterrupted(t, *thread) = true;
|
||||||
monitorRelease(t, local::interruptLock(t, *thread));
|
monitorRelease(t, local::interruptLock(t, *thread));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1577,6 +1577,9 @@ class Classpath {
|
|||||||
virtual object
|
virtual object
|
||||||
makeThread(Thread* t, Thread* parent) = 0;
|
makeThread(Thread* t, Thread* parent) = 0;
|
||||||
|
|
||||||
|
virtual void
|
||||||
|
clearInterrupted(Thread* t) = 0;
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
runThread(Thread* t) = 0;
|
runThread(Thread* t) = 0;
|
||||||
|
|
||||||
@ -3215,6 +3218,7 @@ wait(Thread* t, object o, int64_t milliseconds)
|
|||||||
|
|
||||||
if (interrupted) {
|
if (interrupted) {
|
||||||
if (t->m->alive or (t->flags & Thread::DaemonFlag) == 0) {
|
if (t->m->alive or (t->flags & Thread::DaemonFlag) == 0) {
|
||||||
|
t->m->classpath->clearInterrupted(t);
|
||||||
throwNew(t, Machine::InterruptedExceptionType);
|
throwNew(t, Machine::InterruptedExceptionType);
|
||||||
} else {
|
} else {
|
||||||
throw_(t, root(t, Machine::Shutdown));
|
throw_(t, root(t, Machine::Shutdown));
|
||||||
|
Loading…
Reference in New Issue
Block a user