From e204d5a9966b842e3310c55545f01ed2d675b78a Mon Sep 17 00:00:00 2001 From: akwizgran Date: Thu, 7 May 2020 17:39:17 +0100 Subject: [PATCH] Don't count connections twice. --- .../bramble/plugin/bluetooth/BluetoothPlugin.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bramble-core/src/main/java/org/briarproject/bramble/plugin/bluetooth/BluetoothPlugin.java b/bramble-core/src/main/java/org/briarproject/bramble/plugin/bluetooth/BluetoothPlugin.java index 0dec35bc5..350b0ad1d 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/plugin/bluetooth/BluetoothPlugin.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/plugin/bluetooth/BluetoothPlugin.java @@ -227,9 +227,11 @@ abstract class BluetoothPlugin implements DuplexPlugin, EventListener { if (LOG.isLoggable(INFO)) LOG.info(e.toString()); return; } - backoff.reset(); - if (connectionLimiter.contactConnectionOpened(conn)) + LOG.info("Connection received"); + if (connectionLimiter.contactConnectionOpened(conn)) { + backoff.reset(); callback.handleConnection(conn); + } if (!running) return; } } @@ -273,13 +275,10 @@ abstract class BluetoothPlugin implements DuplexPlugin, EventListener { String uuid = p.get(PROP_UUID); if (isNullOrEmpty(uuid)) return; ioExecutor.execute(() -> { - if (!isRunning() || !shouldAllowContactConnections()) return; - if (!connectionLimiter.canOpenContactConnection()) return; DuplexTransportConnection d = createConnection(p); if (d != null) { backoff.reset(); - if (connectionLimiter.contactConnectionOpened(d)) - h.handleConnection(d); + h.handleConnection(d); } }); } @@ -325,7 +324,6 @@ abstract class BluetoothPlugin implements DuplexPlugin, EventListener { if (isNullOrEmpty(uuid)) return null; DuplexTransportConnection conn = connect(address, uuid); if (conn == null) return null; - // TODO: Why don't we reset the backoff here? return connectionLimiter.contactConnectionOpened(conn) ? conn : null; }