Skip to content

Commit

Permalink
A litle synchronization missing in the page cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacchella committed Nov 7, 2011
1 parent d63ab65 commit 1f1c1cf
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/jrds/caching/PageCache.java
Expand Up @@ -149,22 +149,24 @@ public void write(File file, long offset, byte[] buffer) throws IOException {
* @param pagepointer
*/
private void syncFilePages(Map<Long, FilePage> pagepointer) {
FileChannel channel = null;
for(FilePage page: pagepointer.values()) {
try {
channel = page.sync(channel);
} catch (IOException e) {
logger.error(Util.delayedFormatString("sync failed for %s:", page.filepath, e));
synchronized(pagepointer) {
FileChannel channel = null;
for(FilePage page: pagepointer.values()) {
try {
channel = page.sync(channel);
} catch (IOException e) {
logger.error(Util.delayedFormatString("sync failed for %s:", page.filepath, e));
}
}
}
if(channel!= null) {
try {
channel.force(true);
channel.close();
} catch (IOException e) {
logger.error(Util.delayedFormatString("sync failed for %s: %e", channel, e));
if(channel!= null) {
try {
channel.force(true);
channel.close();
} catch (IOException e) {
logger.error(Util.delayedFormatString("sync failed for %s: %e", channel, e));
}
}
}
}
}

public void sync() {
Expand Down

0 comments on commit 1f1c1cf

Please sign in to comment.