mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Locking.
This commit is contained in:
@@ -18,7 +18,7 @@ public class OutgoingStreamConnection extends StreamConnection {
|
|||||||
|
|
||||||
private final TransportId transportId;
|
private final TransportId transportId;
|
||||||
|
|
||||||
private long connectionNum = -1L;
|
private long connectionNum = -1L; // Locking: this
|
||||||
|
|
||||||
OutgoingStreamConnection(ConnectionReaderFactory connReaderFactory,
|
OutgoingStreamConnection(ConnectionReaderFactory connReaderFactory,
|
||||||
ConnectionWriterFactory connWriterFactory, DatabaseComponent db,
|
ConnectionWriterFactory connWriterFactory, DatabaseComponent db,
|
||||||
@@ -33,8 +33,10 @@ public class OutgoingStreamConnection extends StreamConnection {
|
|||||||
@Override
|
@Override
|
||||||
protected ConnectionReader createConnectionReader() throws DbException,
|
protected ConnectionReader createConnectionReader() throws DbException,
|
||||||
IOException {
|
IOException {
|
||||||
if(connectionNum == -1L)
|
synchronized(this) {
|
||||||
connectionNum = db.getConnectionNumber(contactId, transportId);
|
if(connectionNum == -1L)
|
||||||
|
connectionNum = db.getConnectionNumber(contactId, transportId);
|
||||||
|
}
|
||||||
byte[] secret = db.getSharedSecret(contactId);
|
byte[] secret = db.getSharedSecret(contactId);
|
||||||
return connReaderFactory.createConnectionReader(
|
return connReaderFactory.createConnectionReader(
|
||||||
connection.getInputStream(), false, transportId, connectionNum,
|
connection.getInputStream(), false, transportId, connectionNum,
|
||||||
@@ -44,8 +46,10 @@ public class OutgoingStreamConnection extends StreamConnection {
|
|||||||
@Override
|
@Override
|
||||||
protected ConnectionWriter createConnectionWriter() throws DbException,
|
protected ConnectionWriter createConnectionWriter() throws DbException,
|
||||||
IOException {
|
IOException {
|
||||||
if(connectionNum == -1L)
|
synchronized(this) {
|
||||||
connectionNum = db.getConnectionNumber(contactId, transportId);
|
if(connectionNum == -1L)
|
||||||
|
connectionNum = db.getConnectionNumber(contactId, transportId);
|
||||||
|
}
|
||||||
byte[] secret = db.getSharedSecret(contactId);
|
byte[] secret = db.getSharedSecret(contactId);
|
||||||
return connWriterFactory.createConnectionWriter(
|
return connWriterFactory.createConnectionWriter(
|
||||||
connection.getOutputStream(), Long.MAX_VALUE, true, transportId,
|
connection.getOutputStream(), Long.MAX_VALUE, true, transportId,
|
||||||
|
|||||||
Reference in New Issue
Block a user