Optimize blinear closed file cleanup logic
This commit is contained in:
+3
-5
@@ -459,6 +459,9 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
return;
|
||||
}
|
||||
|
||||
// remove from flusher
|
||||
this.markClosed();
|
||||
|
||||
IOException failure = null;
|
||||
|
||||
// final sync so no buffered data is lost; holding syncLock also guarantees no
|
||||
@@ -473,8 +476,6 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
}
|
||||
|
||||
try {
|
||||
this.markClosed();
|
||||
|
||||
this.swapFileChannel.close();
|
||||
} catch (IOException ex) {
|
||||
if (failure == null) failure = ex;
|
||||
@@ -488,9 +489,6 @@ public class BufferedLinearRegionFile implements io.nanachiyo0721.shiroha.data.R
|
||||
else failure.addSuppressed(e);
|
||||
}
|
||||
|
||||
// finalize
|
||||
this.markClosed();
|
||||
|
||||
if (failure != null) {
|
||||
throw failure;
|
||||
}
|
||||
|
||||
+1
-10
@@ -62,7 +62,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
copied = this.inManagement.toArray(new BufferedLinearRegionFile[0]);
|
||||
}
|
||||
|
||||
final List<BufferedLinearRegionFile> toRemove = new ObjectArrayList<>();
|
||||
for (BufferedLinearRegionFile file : copied) {
|
||||
// try acquiring the read lock
|
||||
if (!file.softReadLock()) {
|
||||
@@ -80,8 +79,7 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
}
|
||||
|
||||
if (closed) {
|
||||
// add to pending remove list so that we could clean the closed file correctly
|
||||
toRemove.add(file);
|
||||
// closed already, should be removed soon
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -109,13 +107,6 @@ public class BufferedLinearRegionFileFlusher implements Runnable {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
// clean closed files
|
||||
for (BufferedLinearRegionFile file : toRemove) {
|
||||
this.inManagement.remove(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFile(BufferedLinearRegionFile fileToRemove) {
|
||||
|
||||
Reference in New Issue
Block a user