summaryrefslogtreecommitdiffstats
path: root/java/jni/direct_bt/DBTManager.cxx
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-04-20 12:05:07 +0200
committerSven Gothel <[email protected]>2020-04-20 12:05:07 +0200
commitd123b2363692d4e95340aa63bf5246cd293b4f30 (patch)
treeca8188107f8a1f47505c6744b463be0404fc1d17 /java/jni/direct_bt/DBTManager.cxx
parentf6fcec6415006918c0d938659379034fad9a2c72 (diff)
HCIComm thread safety, resolve deadlock; Renaming: MgmtHandler -> DBTManager, revert DBTSession -> HCISession
HCIComm thread safety With the java DBTAdapter, we have introduces multithreading access to the HCIComm instance: start/stop etc + discovery-thread. We have experienced a deadlock issuing stopDiscovery() while the discovery-thread is in progress. HCIComm and its dd is now locked using a recursive mutex, which is also being exposed to HCISession allowing DBTAdapter's discovery to use it as well. +++ Renaming: MgmtHandler -> DBTManager, revert DBTSession -> HCISession HCISession is not a major DBT (direct-bt) (java) instance and actually describing the HCI(Comm) session. DBTManager is a major DBT java instance, mapped. Hence also splitting MgmtComm.* -> MgmtTypes.* + DBTManager.*
Diffstat (limited to 'java/jni/direct_bt/DBTManager.cxx')
-rw-r--r--java/jni/direct_bt/DBTManager.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx
index fab3451f..063a716d 100644
--- a/java/jni/direct_bt/DBTManager.cxx
+++ b/java/jni/direct_bt/DBTManager.cxx
@@ -39,8 +39,8 @@ using namespace direct_bt;
void Java_direct_1bt_tinyb_DBTManager_initImpl(JNIEnv *env, jobject obj)
{
try {
- MgmtHandler *manager = &MgmtHandler::get(); // special: static singleton
- setInstance<MgmtHandler>(env, obj, manager);
+ DBTManager *manager = &DBTManager::get(); // special: static singleton
+ setInstance<DBTManager>(env, obj, manager);
manager->setJavaObject( std::shared_ptr<JavaAnonObj>( new JavaGlobalObj(obj) ) );
JavaGlobalObj::check(manager->getJavaObject(), E_FILE_LINE);
DBG_PRINT("Java_direct_1bt_tinyb_DBTManager_init: Manager %s", manager->toString().c_str());
@@ -50,7 +50,7 @@ void Java_direct_1bt_tinyb_DBTManager_initImpl(JNIEnv *env, jobject obj)
void Java_direct_1bt_tinyb_DBTManager_deleteImpl(JNIEnv *env, jobject obj)
{
try {
- MgmtHandler *manager = getInstance<MgmtHandler>(env, obj); // special: static singleton
+ DBTManager *manager = getInstance<DBTManager>(env, obj); // special: static singleton
manager->setJavaObject(nullptr);
// delete manager;
(void) manager;
@@ -62,7 +62,7 @@ static const std::string _adapterClazzCtorArgs("(JLjava/lang/String;Ljava/lang/S
jobject Java_direct_1bt_tinyb_DBTManager_getDefaultAdapterImpl(JNIEnv *env, jobject obj)
{
try {
- MgmtHandler *manager = getInstance<MgmtHandler>(env, obj);
+ DBTManager *manager = getInstance<DBTManager>(env, obj);
DBG_PRINT("Java_direct_1bt_tinyb_DBTManager_getDefaultAdapterImpl: Manager %s", manager->toString().c_str());
int defAdapterIdx = manager->getDefaultAdapterIdx();
DBTAdapter * adapter = new DBTAdapter(defAdapterIdx);
@@ -74,7 +74,7 @@ jobject Java_direct_1bt_tinyb_DBTManager_getDefaultAdapterImpl(JNIEnv *env, jobj
delete adapter;
throw BluetoothException("Invalid default adapter dev-id "+std::to_string(defAdapterIdx), E_FILE_LINE);
}
- std::shared_ptr<direct_bt::DBTSession> session = adapter->open();
+ std::shared_ptr<direct_bt::HCISession> session = adapter->open();
if( nullptr == session ) {
delete adapter;
throw BluetoothException("Couldn't open default adapter "+std::to_string(defAdapterIdx), E_FILE_LINE);