Skip to content

Commit

Permalink
8311981: Test gc/stringdedup/TestStringDeduplicationAgeThreshold.java…
Browse files Browse the repository at this point in the history
…#ZGenerational timed out

Backport-of: f142470deaebbf9cff7f6f28842972393506b7c4
  • Loading branch information
David Holmes committed Aug 23, 2023
1 parent 89aea0d commit 3d38c53
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/hotspot/share/runtime/handshake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,17 @@ HandshakeOperation* HandshakeState::get_op_for_self(bool allow_suspend, bool che
}

bool HandshakeState::has_operation(bool allow_suspend, bool check_async_exception) {
MutexLocker ml(&_lock, Mutex::_no_safepoint_check_flag);
return get_op_for_self(allow_suspend, check_async_exception) != nullptr;
// We must not block here as that could lead to deadlocks if we already hold an
// "external" mutex. If the try_lock fails then we assume that there is an operation
// and force the caller to check more carefully in a safer context. If we can't get
// the lock it means another thread is trying to handshake with us, so it can't
// happen during thread termination and destruction.
bool ret = true;
if (_lock.try_lock()) {
ret = get_op_for_self(allow_suspend, check_async_exception) != nullptr;
_lock.unlock();
}
return ret;
}

bool HandshakeState::has_async_exception_operation() {
Expand Down

1 comment on commit 3d38c53

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.