Skip to content

Commit 13bb792

Browse files
committed
[bugfix] Fix a livelock issue in MultiLock.Sync.tryAcquireShared(long).
The try method could previously block indefinetly when a thread tried to acquire a mode. Such an example is t1 acquires IX, and then t2 acquires S; causing t2 to spin indefinetly. CompatibilityTest surfaced the issue.
1 parent 2460fb3 commit 13bb792

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/main/java/uk/ac/ic/doc/slurp/multilock/MultiLock.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ else if (arg == IX_UNIT) {
306306
cachedHoldCounter = rh;
307307
return 1; // still return 1 because IS is always compatible
308308
}
309+
} else {
310+
return -1;
309311
}
310312
}
311313
}
@@ -332,6 +334,8 @@ else if (arg == S_UNIT) {
332334
cachedHoldCounter = rh;
333335
return 1; // still return 1 because IS is always compatible
334336
}
337+
} else {
338+
return -1;
335339
}
336340
}
337341
}

0 commit comments

Comments
 (0)