mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-27 11:07:38 +01:00
Fix premature timeouts on tile read waits, causing missed tile loads
This commit is contained in:
parent
97ff6a2c2d
commit
e724a7bccb
@ -72,7 +72,9 @@ public class FileLockManager {
|
||||
String fn = f.getPath();
|
||||
synchronized(lock) {
|
||||
boolean got_lock = false;
|
||||
boolean first_wait = true;
|
||||
long starttime = 0;
|
||||
if(timeout > 0)
|
||||
starttime = System.currentTimeMillis();
|
||||
while(!got_lock) {
|
||||
Integer lockcnt = filelocks.get(fn); /* Get lock count */
|
||||
if(lockcnt == null) {
|
||||
@ -85,14 +87,16 @@ public class FileLockManager {
|
||||
}
|
||||
else { /* Write lock in place */
|
||||
try {
|
||||
if((timeout > 0) && (!first_wait)) { /* We already waited */
|
||||
return false;
|
||||
}
|
||||
if(timeout < 0)
|
||||
if(timeout < 0) {
|
||||
lock.wait();
|
||||
else
|
||||
lock.wait(timeout);
|
||||
first_wait = false;
|
||||
}
|
||||
else {
|
||||
long now = System.currentTimeMillis();
|
||||
long elapsed = now-starttime;
|
||||
if(elapsed > timeout) /* Give up on timeout */
|
||||
return false;
|
||||
lock.wait(timeout-elapsed);
|
||||
}
|
||||
} catch (InterruptedException ix) {
|
||||
Log.severe("getReadLock(" + fn + ") interrupted");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user