Skip to content
Snippets Groups Projects
Commit cb06ebc5 authored by akwizgran's avatar akwizgran
Browse files

Locking.

parent 0d115531
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,7 @@ public class OutgoingStreamConnection extends StreamConnection {
private final TransportId transportId;
private long connectionNum = -1L;
private long connectionNum = -1L; // Locking: this
OutgoingStreamConnection(ConnectionReaderFactory connReaderFactory,
ConnectionWriterFactory connWriterFactory, DatabaseComponent db,
......@@ -33,8 +33,10 @@ public class OutgoingStreamConnection extends StreamConnection {
@Override
protected ConnectionReader createConnectionReader() throws DbException,
IOException {
if(connectionNum == -1L)
connectionNum = db.getConnectionNumber(contactId, transportId);
synchronized(this) {
if(connectionNum == -1L)
connectionNum = db.getConnectionNumber(contactId, transportId);
}
byte[] secret = db.getSharedSecret(contactId);
return connReaderFactory.createConnectionReader(
connection.getInputStream(), false, transportId, connectionNum,
......@@ -44,8 +46,10 @@ public class OutgoingStreamConnection extends StreamConnection {
@Override
protected ConnectionWriter createConnectionWriter() throws DbException,
IOException {
if(connectionNum == -1L)
connectionNum = db.getConnectionNumber(contactId, transportId);
synchronized(this) {
if(connectionNum == -1L)
connectionNum = db.getConnectionNumber(contactId, transportId);
}
byte[] secret = db.getSharedSecret(contactId);
return connWriterFactory.createConnectionWriter(
connection.getOutputStream(), Long.MAX_VALUE, true, transportId,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment