mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Fixed a race conditon when adding a transport and then an endpoint.
To fix issue #3611966, KeyManagerImpl's handling of TransportAddedEvent was made asynchronous. This made it possible for a thread to call KeyManager.endpointAdded() before the KeyManager had asynchronously handled the TransportAddedEvent from a previous call to DatabaseComponent.addTransport().
This commit is contained in:
@@ -125,7 +125,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
db.addTransport(transportId, LATENCY);
|
||||
Endpoint ep = new Endpoint(contactId, transportId, epoch, true);
|
||||
db.addEndpoint(ep);
|
||||
km.endpointAdded(ep, initialSecret.clone());
|
||||
km.endpointAdded(ep, LATENCY, initialSecret.clone());
|
||||
// Send Bob a message
|
||||
String contentType = "text/plain";
|
||||
byte[] body = "Hi Bob!".getBytes("UTF-8");
|
||||
@@ -179,7 +179,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
db.addTransport(transportId, LATENCY);
|
||||
Endpoint ep = new Endpoint(contactId, transportId, epoch, false);
|
||||
db.addEndpoint(ep);
|
||||
km.endpointAdded(ep, initialSecret.clone());
|
||||
km.endpointAdded(ep, LATENCY, initialSecret.clone());
|
||||
// Set up a database listener
|
||||
MessageListener listener = new MessageListener();
|
||||
db.addListener(listener);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
keyManager.endpointAdded(ep, initialSecret.clone());
|
||||
keyManager.endpointAdded(ep, MAX_LATENCY, initialSecret.clone());
|
||||
keyManager.stop();
|
||||
|
||||
context.assertIsSatisfied();
|
||||
@@ -202,7 +202,7 @@ public class KeyManagerImplTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
keyManager.endpointAdded(ep, initialSecret.clone());
|
||||
keyManager.endpointAdded(ep, MAX_LATENCY, initialSecret.clone());
|
||||
ConnectionContext ctx =
|
||||
keyManager.getConnectionContext(contactId, transportId);
|
||||
assertNotNull(ctx);
|
||||
|
||||
@@ -239,7 +239,7 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
keyManager.endpointAdded(ep, initialSecret.clone());
|
||||
keyManager.endpointAdded(ep, MAX_LATENCY, initialSecret.clone());
|
||||
keyManager.stop();
|
||||
|
||||
context.assertIsSatisfied();
|
||||
@@ -377,7 +377,7 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
keyManager.endpointAdded(ep, initialSecret.clone());
|
||||
keyManager.endpointAdded(ep, MAX_LATENCY, initialSecret.clone());
|
||||
ConnectionContext ctx =
|
||||
keyManager.getConnectionContext(contactId, transportId);
|
||||
assertNotNull(ctx);
|
||||
@@ -533,7 +533,7 @@ public class KeyRotationIntegrationTest extends BriarTestCase {
|
||||
}});
|
||||
|
||||
assertTrue(keyManager.start());
|
||||
keyManager.endpointAdded(ep, initialSecret.clone());
|
||||
keyManager.endpointAdded(ep, MAX_LATENCY, initialSecret.clone());
|
||||
// Recognise the tag for connection 0 in period 2
|
||||
byte[] tag = new byte[TAG_LENGTH];
|
||||
encodeTag(tag, key2, 0);
|
||||
|
||||
Reference in New Issue
Block a user