summaryrefslogtreecommitdiffstats
path: root/java/direct_bt/tinyb/DBTDevice.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-30 11:07:13 +0200
committerSven Gothel <[email protected]>2020-09-30 11:07:13 +0200
commitbda1e0d415257544c94ebfff87af8424166dd316 (patch)
tree4c88f6b0b1897b0bb3eccb012109cd6705032882 /java/direct_bt/tinyb/DBTDevice.java
parent95f4fec352f679ebab32b80b15d14cfa0042f15b (diff)
DBT[Adapter|Device].close(): Utilize own AtomicBoolean synchronization avoiding reentry; DBTAdapter.removeStatusListener(): Avoid @ within isClosing (warning on failure)
Diffstat (limited to 'java/direct_bt/tinyb/DBTDevice.java')
-rw-r--r--java/direct_bt/tinyb/DBTDevice.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/java/direct_bt/tinyb/DBTDevice.java b/java/direct_bt/tinyb/DBTDevice.java
index 0ebd6f34..7e01b122 100644
--- a/java/direct_bt/tinyb/DBTDevice.java
+++ b/java/direct_bt/tinyb/DBTDevice.java
@@ -65,6 +65,8 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
volatile short hciConnHandle;
/* pp */ final List<WeakReference<DBTGattService>> serviceCache = new ArrayList<WeakReference<DBTGattService>>();
+ private final AtomicBoolean isClosing = new AtomicBoolean(false);
+
private final Object userCallbackLock = new Object();
private final long blockedNotificationRef = 0;
@@ -239,10 +241,13 @@ public class DBTDevice extends DBTObject implements BluetoothDevice
}
@Override
- public synchronized void close() {
+ public void close() {
if( !isValid() ) {
return;
}
+ if( !isClosing.compareAndSet(false, true) ) {
+ return;
+ }
disableConnectedNotifications();
disableRSSINotifications();
disableManufacturerDataNotifications();