mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-22 07:39:53 +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.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@@ -31,9 +30,8 @@ class H2Database extends JdbcDatabase {
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
File dir = config.getDatabaseDirectory();
|
File dir = config.getDatabaseDirectory();
|
||||||
String path = new File(dir, "db").getAbsolutePath();
|
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"
|
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 {
|
public boolean open() throws DbException {
|
||||||
@@ -83,10 +81,4 @@ class H2Database extends JdbcDatabase {
|
|||||||
props.put("password", StringUtils.toHexString(key) + " password");
|
props.put("password", StringUtils.toHexString(key) + " password");
|
||||||
return DriverManager.getConnection(url, props);
|
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 Connection createConnection() throws SQLException;
|
||||||
|
|
||||||
protected abstract void flushBuffersToDisk(Statement s) throws SQLException;
|
|
||||||
|
|
||||||
private final Lock connectionsLock = new ReentrantLock();
|
private final Lock connectionsLock = new ReentrantLock();
|
||||||
private final Condition connectionsChanged = connectionsLock.newCondition();
|
private final Condition connectionsChanged = connectionsLock.newCondition();
|
||||||
|
|
||||||
@@ -419,14 +417,9 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void commitTransaction(Connection txn) throws DbException {
|
public void commitTransaction(Connection txn) throws DbException {
|
||||||
Statement s = null;
|
|
||||||
try {
|
try {
|
||||||
txn.commit();
|
txn.commit();
|
||||||
s = txn.createStatement();
|
|
||||||
flushBuffersToDisk(s);
|
|
||||||
s.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
tryToClose(s);
|
|
||||||
throw new DbException(e);
|
throw new DbException(e);
|
||||||
}
|
}
|
||||||
connectionsLock.lock();
|
connectionsLock.lock();
|
||||||
|
|||||||
Reference in New Issue
Block a user