Mercurial > hg > graal-compiler
comparison src/os/windows/vm/os_windows.cpp @ 2386:083f13976b51
6535709: interrupt of wait()ing thread isn't triggerring InterruptedException - test intwait3
Summary: only clear the interrupt state if we will report that it was set
Reviewed-by: dcubed, alanb, phh, coleenp, dice
author | dholmes |
---|---|
date | Mon, 21 Mar 2011 22:16:19 -0400 |
parents | 5584e20db481 |
children | 8b0236cbed14 5504afd15955 5def270bc147 |
comparison
equal
deleted
inserted
replaced
2372:b898f0fc3ced | 2386:083f13976b51 |
---|---|
3295 bool os::is_interrupted(Thread* thread, bool clear_interrupted) { | 3295 bool os::is_interrupted(Thread* thread, bool clear_interrupted) { |
3296 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), | 3296 assert(!thread->is_Java_thread() || Thread::current() == thread || Threads_lock->owned_by_self(), |
3297 "possibility of dangling Thread pointer"); | 3297 "possibility of dangling Thread pointer"); |
3298 | 3298 |
3299 OSThread* osthread = thread->osthread(); | 3299 OSThread* osthread = thread->osthread(); |
3300 bool interrupted; | 3300 bool interrupted = osthread->interrupted(); |
3301 interrupted = osthread->interrupted(); | 3301 // There is no synchronization between the setting of the interrupt |
3302 if (clear_interrupted == true) { | 3302 // and it being cleared here. It is critical - see 6535709 - that |
3303 // we only clear the interrupt state, and reset the interrupt event, | |
3304 // if we are going to report that we were indeed interrupted - else | |
3305 // an interrupt can be "lost", leading to spurious wakeups or lost wakeups | |
3306 // depending on the timing | |
3307 if (interrupted && clear_interrupted) { | |
3303 osthread->set_interrupted(false); | 3308 osthread->set_interrupted(false); |
3304 ResetEvent(osthread->interrupt_event()); | 3309 ResetEvent(osthread->interrupt_event()); |
3305 } // Otherwise leave the interrupted state alone | 3310 } // Otherwise leave the interrupted state alone |
3306 | 3311 |
3307 return interrupted; | 3312 return interrupted; |