mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Don't flush buffers on every commit.
This was meant to prevent key reuse with BTPv1, it's no longer needed with BTPv2.
This commit is contained in:
@@ -9,7 +9,6 @@ import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -31,9 +30,8 @@ class H2Database extends JdbcDatabase {
|
||||
this.config = config;
|
||||
File dir = config.getDatabaseDirectory();
|
||||
String path = new File(dir, "db").getAbsolutePath();
|
||||
// FIXME: Remove WRITE_DELAY=0 after implementing BTPv2?
|
||||
url = "jdbc:h2:split:" + path + ";CIPHER=AES;MULTI_THREADED=1"
|
||||
+ ";WRITE_DELAY=0;DB_CLOSE_ON_EXIT=false";
|
||||
+ ";DB_CLOSE_ON_EXIT=false";
|
||||
}
|
||||
|
||||
public boolean open() throws DbException {
|
||||
@@ -83,10 +81,4 @@ class H2Database extends JdbcDatabase {
|
||||
props.put("password", StringUtils.toHexString(key) + " password");
|
||||
return DriverManager.getConnection(url, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void flushBuffersToDisk(Statement s) throws SQLException {
|
||||
// FIXME: Remove this after implementing BTPv2?
|
||||
s.execute("CHECKPOINT SYNC");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,8 +256,6 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
|
||||
protected abstract Connection createConnection() throws SQLException;
|
||||
|
||||
protected abstract void flushBuffersToDisk(Statement s) throws SQLException;
|
||||
|
||||
private final Lock connectionsLock = new ReentrantLock();
|
||||
private final Condition connectionsChanged = connectionsLock.newCondition();
|
||||
|
||||
@@ -419,14 +417,9 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
|
||||
public void commitTransaction(Connection txn) throws DbException {
|
||||
Statement s = null;
|
||||
try {
|
||||
txn.commit();
|
||||
s = txn.createStatement();
|
||||
flushBuffersToDisk(s);
|
||||
s.close();
|
||||
} catch (SQLException e) {
|
||||
tryToClose(s);
|
||||
throw new DbException(e);
|
||||
}
|
||||
connectionsLock.lock();
|
||||
|
||||
Reference in New Issue
Block a user