Skip to content

Commit

Permalink
remove possibility for race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
dordsor21 committed Oct 11, 2023
1 parent 2142257 commit 14804a0
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,16 @@ public void setTimezone(ZoneId timezone) {
*/
public void clearHistory() {
//FAWE start
if (Fawe.isMainThread() && historyWriteLock.isLocked()) {
if (Fawe.isMainThread() && !historyWriteLock.tryLock()) {
// Do not make main thread wait if we cannot immediately clear history (on player logout usually)
TaskManager.taskManager().async(this::clearHistoryTask);
return;
}
clearHistoryTask();
try {
clearHistoryTask();
} finally {
historyWriteLock.unlock();
}
}

private void clearHistoryTask() {
Expand Down

0 comments on commit 14804a0

Please sign in to comment.