Author: toad
Date: 2006-09-02 13:42:03 +0000 (Sat, 02 Sep 2006)
New Revision: 10348
Modified:
trunk/freenet/src/freenet/config/FilePersistentConfig.java
Log:
Don't allow overlapping config stores.
Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/FilePersistentConfig.java 2006-09-02
13:39:34 UTC (rev 10347)
+++ trunk/freenet/src/freenet/config/FilePersistentConfig.java 2006-09-02
13:42:03 UTC (rev 10348)
@@ -30,6 +30,7 @@
final File tempFilename;
private SimpleFieldSet origConfigFileContents;
private boolean finishedInit;
+ private final Object storeSync = new Object();
public FilePersistentConfig(File f) throws IOException {
this.filename = f;
@@ -123,7 +124,9 @@
}
}
try {
- innerStore();
+ synchronized(storeSync) {
+ innerStore();
+ }
} catch (IOException e) {
String err = "Cannot store config: "+e;
Logger.error(this, err, e);
@@ -132,7 +135,8 @@
}
}
- public void innerStore() throws IOException {
+ /** Don't call without taking storeSync first */
+ private void innerStore() throws IOException {
SimpleFieldSet fs = exportFieldSet();
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "fs = "+fs);