mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 18:14:38 +02:00
8047720: Xprof hangs on Solaris
Update use of PeriodicTask_lock in WatcherThread::stop() to avoid safepoint deadlock. Reviewed-by: mgronlun, coleenp
This commit is contained in:
parent
628b3c2c3a
commit
8f73a84a15
1 changed files with 15 additions and 5 deletions
|
@ -1358,16 +1358,26 @@ void WatcherThread::make_startable() {
|
|||
}
|
||||
|
||||
void WatcherThread::stop() {
|
||||
{
|
||||
MutexLockerEx ml(PeriodicTask_lock, Mutex::_no_safepoint_check_flag);
|
||||
// Get the PeriodicTask_lock if we can. If we cannot, then the
|
||||
// WatcherThread is using it and we don't want to block on that lock
|
||||
// here because that might cause a safepoint deadlock depending on
|
||||
// what the current WatcherThread tasks are doing.
|
||||
bool have_lock = PeriodicTask_lock->try_lock();
|
||||
|
||||
_should_terminate = true;
|
||||
OrderAccess::fence(); // ensure WatcherThread sees update in main loop
|
||||
|
||||
if (have_lock) {
|
||||
WatcherThread* watcher = watcher_thread();
|
||||
if (watcher != NULL)
|
||||
if (watcher != NULL) {
|
||||
// If we managed to get the lock, then we should unpark the
|
||||
// WatcherThread so that it can see we want it to stop.
|
||||
watcher->unpark();
|
||||
}
|
||||
|
||||
PeriodicTask_lock->unlock();
|
||||
}
|
||||
|
||||
// it is ok to take late safepoints here, if needed
|
||||
MutexLocker mu(Terminator_lock);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue