Skip to content

Commit

Permalink
Pending transaction threads should exit when they timed out waiting, …
Browse files Browse the repository at this point in the history
…not sooner.
  • Loading branch information
broneill committed Oct 17, 2024
1 parent cc38444 commit 165de50
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/org/cojen/tupl/core/PendingTxnFinisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void interrupt() {
@Override
public void run() {
while (true) {
boolean waited = false;
int awaitResult = 1; // signaled
PendingTxn pending;
acquireExclusive();
try {
Expand All @@ -89,7 +89,8 @@ public void run() {
}
break;
}
if (waited) {

if (awaitResult <= 0) { // interrupted or timed out
mTotalThreads--;
return;
}
Expand All @@ -99,9 +100,7 @@ public void run() {
// closely match the amount that's needed.
long nanosTimeout = 10_000_000_000L;
long nanosEnd = System.nanoTime() + nanosTimeout;
mIdleCondition.priorityAwait(this, nanosTimeout, nanosEnd);

waited = true;
awaitResult = mIdleCondition.priorityAwait(this, nanosTimeout, nanosEnd);
}
} finally {
releaseExclusive();
Expand Down

0 comments on commit 165de50

Please sign in to comment.