celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1646384 - /celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
Date Thu, 18 Dec 2014 05:25:36 GMT
Author: bpetri
Date: Thu Dec 18 05:25:35 2014
New Revision: 1646384

URL: http://svn.apache.org/r1646384
Log:
CELIX-190: added missing hashMap cleanup

Modified:
    celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1646384&r1=1646383&r2=1646384&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/topology_manager.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/topology_manager.c Thu Dec 18
05:25:35 2014
@@ -193,6 +193,11 @@ celix_status_t topologyManager_rsaAdded(
 
 		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);
 		}
@@ -228,7 +233,11 @@ celix_status_t topologyManager_rsaRemove
     while (hashMapIterator_hasNext(iter)) {
         int exportsIter = 0;
 
-        hash_map_pt exports = hashMapIterator_nextValue(iter);
+        hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+
+        service_reference_pt key = hashMapEntry_getKey(entry);
+        hash_map_pt exports = hashMapEntry_getValue(entry);
+
         array_list_pt exports_list = hashMap_get(exports, rsa);
 
         if (exports_list != NULL) {
@@ -243,6 +252,15 @@ celix_status_t topologyManager_rsaRemove
         }
 
         hashMap_remove(exports, rsa);
+
+        if (hashMap_size(exports) == 0) {
+        	hashMap_remove(manager->exportedServices, key);
+        	hashMap_destroy(exports, false, false);
+
+            hashMapIterator_destroy(iter);
+            iter = hashMapIterator_create(manager->exportedServices);
+        }
+
     }
 
     hashMapIterator_destroy(iter);
@@ -365,7 +383,6 @@ celix_status_t topologyManager_removeImp
                     hashMap_remove(imports, rsa);
                 }
             }
-
             hashMapIterator_destroy(importsIter);
 	    }
 	}



Mime
View raw message