keep rsaRemoved and rsaAdded strictly reverse order
@@ -288,16 +288,13 @@ celix_status_t topologyManager_rsaRemoved(void * handle, service_reference_pt re
topology_manager_pt manager = (topology_manager_pt) handle;
remote_service_admin_service_t *rsa = (remote_service_admin_service_t *) service;
- celixThreadMutex_lock(&manager->rsaListLock);
- arrayList_removeElement(manager->rsaList, rsa);
- celixThreadMutex_unlock(&manager->rsaListLock);
+ celixThreadMutex_lock(&manager->exportedServicesLock);
- if (celixThreadMutex_lock(&manager->exportedServicesLock) == CELIX_SUCCESS) {
- hash_map_iterator_pt iter = hashMapIterator_create(manager->exportedServices);
+ hash_map_iterator_pt exportedSvcIter = hashMapIterator_create(manager->exportedServices);
- while (hashMapIterator_hasNext(iter)) {
+ while (hashMapIterator_hasNext(exportedSvcIter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(exportedSvcIter);
service_reference_pt key = hashMapEntry_getKey(entry);
hash_map_pt exports = hashMapEntry_getValue(entry);
@@ -326,19 +323,18 @@ celix_status_t topologyManager_rsaRemoved(void * handle, service_reference_pt re
hashMap_remove(manager->exportedServices, key);
hashMap_destroy(exports, false, false);
- hashMapIterator_destroy(iter);
- iter = hashMapIterator_create(manager->exportedServices);
- }
+ hashMapIterator_destroy(exportedSvcIter);
+ exportedSvcIter = hashMapIterator_create(manager->exportedServices);
}
- hashMapIterator_destroy(iter);
- celixThreadMutex_unlock(&manager->exportedServicesLock);
}
+ hashMapIterator_destroy(exportedSvcIter);
- if (celixThreadMutex_lock(&manager->importedServicesLock) == CELIX_SUCCESS) {
- hash_map_iterator_pt iter = hashMapIterator_create(manager->importedServices);
+ celixThreadMutex_lock(&manager->importedServicesLock);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ hash_map_iterator_pt importedSvcIter = hashMapIterator_create(manager->importedServices);
+
+ while (hashMapIterator_hasNext(importedSvcIter)) {
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(importedSvcIter);
hash_map_pt imports = hashMapEntry_getValue(entry);
import_registration_t *import = hashMap_get(imports, rsa);
@@ -353,9 +349,14 @@ celix_status_t topologyManager_rsaRemoved(void * handle, service_reference_pt re
}
}
}
- hashMapIterator_destroy(iter);
+ hashMapIterator_destroy(importedSvcIter);
+
+ celixThreadMutex_lock(&manager->rsaListLock);
+ arrayList_removeElement(manager->rsaList, rsa);
+ celixThreadMutex_unlock(&manager->rsaListLock);
+
celixThreadMutex_unlock(&manager->importedServicesLock);
- }
+ celixThreadMutex_unlock(&manager->exportedServicesLock);
celix_logHelper_log(manager->loghelper, CELIX_LOG_LEVEL_INFO, "TOPOLOGY_MANAGER: Removed RSA");
