Don't count connections twice.

This commit is contained in:
akwizgran
2020-05-07 17:39:17 +01:00
parent 8fd9a40ffb
commit e204d5a996

View File

@@ -227,9 +227,11 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
if (LOG.isLoggable(INFO)) LOG.info(e.toString()); if (LOG.isLoggable(INFO)) LOG.info(e.toString());
return; return;
} }
backoff.reset(); LOG.info("Connection received");
if (connectionLimiter.contactConnectionOpened(conn)) if (connectionLimiter.contactConnectionOpened(conn)) {
backoff.reset();
callback.handleConnection(conn); callback.handleConnection(conn);
}
if (!running) return; if (!running) return;
} }
} }
@@ -273,13 +275,10 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
String uuid = p.get(PROP_UUID); String uuid = p.get(PROP_UUID);
if (isNullOrEmpty(uuid)) return; if (isNullOrEmpty(uuid)) return;
ioExecutor.execute(() -> { ioExecutor.execute(() -> {
if (!isRunning() || !shouldAllowContactConnections()) return;
if (!connectionLimiter.canOpenContactConnection()) return;
DuplexTransportConnection d = createConnection(p); DuplexTransportConnection d = createConnection(p);
if (d != null) { if (d != null) {
backoff.reset(); backoff.reset();
if (connectionLimiter.contactConnectionOpened(d)) h.handleConnection(d);
h.handleConnection(d);
} }
}); });
} }
@@ -325,7 +324,6 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
if (isNullOrEmpty(uuid)) return null; if (isNullOrEmpty(uuid)) return null;
DuplexTransportConnection conn = connect(address, uuid); DuplexTransportConnection conn = connect(address, uuid);
if (conn == null) return null; if (conn == null) return null;
// TODO: Why don't we reset the backoff here?
return connectionLimiter.contactConnectionOpened(conn) ? conn : null; return connectionLimiter.contactConnectionOpened(conn) ? conn : null;
} }