celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject celix git commit: CELIX-276: added handling of importedServices when rsa gets removed.
Date Fri, 16 Oct 2015 10:15:04 GMT
Repository: celix
Updated Branches:
  refs/heads/develop f60ca0de4 -> 48558e8bc


CELIX-276: added handling of importedServices when rsa gets removed.


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/48558e8b
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/48558e8b
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/48558e8b

Branch: refs/heads/develop
Commit: 48558e8bc090979c7866be0c8ccde5d4d89b88ad
Parents: f60ca0d
Author: Bjoern Petri <bpetri@apache.org>
Authored: Fri Oct 16 09:10:31 2015 +0200
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Fri Oct 16 09:10:31 2015 +0200

----------------------------------------------------------------------
 .../private/include/topology_manager.h          |  2 +
 .../topology_manager/private/src/activator.c    |  2 +-
 .../private/src/topology_manager.c              | 47 +++++++++++++-------
 3 files changed, 33 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/48558e8b/remote_services/topology_manager/private/include/topology_manager.h
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/private/include/topology_manager.h b/remote_services/topology_manager/private/include/topology_manager.h
index f0f9884..ade5a1e 100644
--- a/remote_services/topology_manager/private/include/topology_manager.h
+++ b/remote_services/topology_manager/private/include/topology_manager.h
@@ -32,6 +32,8 @@
 #include "bundle_context.h"
 #include "log_helper.h"
 
+#define OSGI_RSA_REMOTE_SERVICE_ADMIN "remote_service_admin"
+
 typedef struct topology_manager *topology_manager_pt;
 
 celix_status_t topologyManager_create(bundle_context_pt context, log_helper_pt logHelper,
topology_manager_pt *manager);

http://git-wip-us.apache.org/repos/asf/celix/blob/48558e8b/remote_services/topology_manager/private/src/activator.c
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/private/src/activator.c b/remote_services/topology_manager/private/src/activator.c
index b83c060..42046b3 100644
--- a/remote_services/topology_manager/private/src/activator.c
+++ b/remote_services/topology_manager/private/src/activator.c
@@ -124,7 +124,7 @@ static celix_status_t bundleActivator_createRSATracker(struct activator
*activat
     status = serviceTrackerCustomizer_create(activator->manager, topologyManager_rsaAdding,
topologyManager_rsaAdded, topologyManager_rsaModified, topologyManager_rsaRemoved, &customizer);
 
     if (status == CELIX_SUCCESS) {
-        status = serviceTracker_create(activator->context, "remote_service_admin", customizer,
tracker);
+        status = serviceTracker_create(activator->context, OSGI_RSA_REMOTE_SERVICE_ADMIN,
customizer, tracker);
     }
 
     return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/48558e8b/remote_services/topology_manager/private/src/topology_manager.c
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/private/src/topology_manager.c b/remote_services/topology_manager/private/src/topology_manager.c
index f78bde5..68be8c8 100644
--- a/remote_services/topology_manager/private/src/topology_manager.c
+++ b/remote_services/topology_manager/private/src/topology_manager.c
@@ -214,12 +214,7 @@ celix_status_t topologyManager_rsaAdded(void * handle, service_reference_pt
refe
 
         if (status == CELIX_SUCCESS) {
             hash_map_pt imports = hashMapEntry_getValue(entry);
-
-            if (imports == NULL) {
-                imports = hashMap_create(NULL, NULL, NULL, NULL);
-            }
-
-            hashMap_put(imports, service, import);
+            hashMap_put(imports, rsa, import);
         }
     }
 
@@ -244,10 +239,6 @@ celix_status_t topologyManager_rsaAdded(void * handle, service_reference_pt
refe
         if (status == CELIX_SUCCESS) {
             hash_map_pt exports = hashMapEntry_getValue(entry);
 
-            if (exports == NULL) {
-                exports = hashMap_create(NULL, NULL, NULL, NULL);
-            }
-
             hashMap_put(exports, rsa, endpoints);
             status = topologyManager_notifyListenersEndpointAdded(manager, rsa, endpoints);
         }
@@ -317,6 +308,30 @@ celix_status_t topologyManager_rsaRemoved(void * handle, service_reference_pt
re
 
     status = celixThreadMutex_unlock(&manager->exportedServicesLock);
 
+    status = celixThreadMutex_lock(&manager->importedServicesLock);
+
+    iter = hashMapIterator_create(manager->importedServices);
+
+    while (hashMapIterator_hasNext(iter)) {
+        hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+        endpoint_description_pt ep = hashMapEntry_getKey(entry);
+        hash_map_pt imports = hashMapEntry_getValue(entry);
+
+        import_registration_pt import = hashMap_get(imports, rsa);
+
+        if (import != NULL) {
+            status = rsa->importRegistration_close(rsa->admin, import);
+
+            if (status == CELIX_SUCCESS) {
+                hashMap_remove(imports, rsa);
+            }
+        }
+    }
+
+    hashMapIterator_destroy(iter);
+
+    status = celixThreadMutex_unlock(&manager->importedServicesLock);
+
     logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Removed
RSA");
 
     status = celixThreadMutex_lock(&manager->rsaListLock);
@@ -610,7 +625,7 @@ celix_status_t topologyManager_endpointListenerAdded(void* handle, service_refer
 }
 
 celix_status_t topologyManager_endpointListenerModified(void * handle, service_reference_pt
reference, void * service) {
-    celix_status_t status;
+    celix_status_t status = CELIX_SUCCESS;
 
     status = topologyManager_endpointListenerRemoved(handle, reference, service);
     if (status == CELIX_SUCCESS) {
@@ -621,7 +636,7 @@ celix_status_t topologyManager_endpointListenerModified(void * handle,
service_r
 }
 
 celix_status_t topologyManager_endpointListenerRemoved(void * handle, service_reference_pt
reference, void * service) {
-    celix_status_t status;
+    celix_status_t status = CELIX_SUCCESS;
     topology_manager_pt manager = handle;
 
     celixThreadMutex_lock(&manager->listenerListLock);
@@ -638,7 +653,7 @@ celix_status_t topologyManager_endpointListenerRemoved(void * handle,
service_re
 }
 
 celix_status_t topologyManager_notifyListenersEndpointAdded(topology_manager_pt manager,
remote_service_admin_service_pt rsa, array_list_pt registrations) {
-    celix_status_t status;
+    celix_status_t status = CELIX_SUCCESS;
 
     celixThreadMutex_lock(&manager->listenerListLock);
 
@@ -705,12 +720,10 @@ celix_status_t topologyManager_notifyListenersEndpointRemoved(topology_manager_p
         if (status == CELIX_SUCCESS) {
             status = epl->endpointRemoved(epl->handle, endpoint, NULL);
         }
-
-        hashMapIterator_destroy(iter);
-
-
     }
 
+    hashMapIterator_destroy(iter);
+
     celixThreadMutex_unlock(&manager->listenerListLock);
 
     return status;


Mime
View raw message