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-306: Fix remoteProxyFactory
Date Thu, 26 Nov 2015 07:17:45 GMT
Repository: celix
Updated Branches:
  refs/heads/develop c33e47581 -> cc7d09128


CELIX-306: Fix remoteProxyFactory


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

Branch: refs/heads/develop
Commit: cc7d09128e8abd2eaf22ec95ea7dc6e02e35f1bb
Parents: c33e475
Author: Bjoern Petri <bpetri@apache.org>
Authored: Thu Nov 26 08:17:05 2015 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Thu Nov 26 08:17:05 2015 +0100

----------------------------------------------------------------------
 .../private/src/import_registration_impl.c      |  1 -
 .../private/src/remote_proxy_factory_impl.c     | 17 ++++++++---
 .../private/src/remote_service_admin_impl.c     |  6 ++--
 .../private/src/topology_manager.c              |  6 ++--
 .../topology_manager/tms_tst/tms_tests.cpp      | 31 ++++++++++++++------
 5 files changed, 43 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/cc7d0912/remote_services/remote_service_admin/private/src/import_registration_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin/private/src/import_registration_impl.c b/remote_services/remote_service_admin/private/src/import_registration_impl.c
index 52732f6..f7419a2 100644
--- a/remote_services/remote_service_admin/private/src/import_registration_impl.c
+++ b/remote_services/remote_service_admin/private/src/import_registration_impl.c
@@ -209,7 +209,6 @@ celix_status_t importRegistration_proxyFactoryRemoved(void * handle, service_ref
 	import_registration_factory_pt registration_factory = (import_registration_factory_pt) handle;
 	registration_factory->trackedFactory = NULL;
 
-
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cc7d0912/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
index 54d7704..b2ffd29 100644
--- a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
+++ b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c
@@ -129,6 +129,18 @@ celix_status_t remoteProxyFactory_unregister(remote_proxy_factory_pt
remote_prox
 
 	// #TODO Remove proxy registrations
 	if (status == CELIX_SUCCESS) {
+
+		hash_map_iterator_pt iter = hashMapIterator_create(remote_proxy_factory_ptr->proxy_instances);
+		while(hashMapIterator_hasNext(iter)){
+			proxy_instance_pt proxy_instance_ptr = (proxy_instance_pt)hashMapIterator_nextValue(iter);
+
+			if (proxy_instance_ptr->service) {
+				remote_proxy_factory_ptr->destroy_proxy_service_ptr(remote_proxy_factory_ptr->handle,
proxy_instance_ptr->service);
+			}
+			free(proxy_instance_ptr);
+		}
+		hashMapIterator_destroy(iter);
+
 		if (remote_proxy_factory_ptr->registration) {
 			status = serviceRegistration_unregister(remote_proxy_factory_ptr->registration);
 			remote_proxy_factory_ptr->properties = NULL;
@@ -144,6 +156,7 @@ celix_status_t remoteProxyFactory_unregister(remote_proxy_factory_pt remote_prox
 	return status;
 }
 
+
 static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr,
endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback)
{
 	celix_status_t status = CELIX_SUCCESS;
 	proxy_instance_pt proxy_instance_ptr = NULL;
@@ -173,10 +186,6 @@ static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_facto
 	if (status == CELIX_SUCCESS) {
 		properties_set(proxy_instance_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service);
 
-
-
-
-
 		hash_map_iterator_pt iter = hashMapIterator_create(endpointDescription->properties);
 		while (hashMapIterator_hasNext(iter)) {
 			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);

http://git-wip-us.apache.org/repos/asf/celix/blob/cc7d0912/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
index 2420fed..b14b542 100644
--- a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
@@ -679,13 +679,15 @@ celix_status_t remoteServiceAdmin_removeImportedService(remote_service_admin_pt
     registration_factory = (import_registration_factory_pt) hashMap_get(admin->importedServices,
endpointDescription->service);
 
     // factory available
-    if ((registration_factory == NULL) || (registration_factory->trackedFactory == NULL))
+    if (registration_factory == NULL)
     {
     	logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "RSA: Error while retrieving
registration factory for imported service %s", endpointDescription->service);
     }
     else
     {
-		registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory,
endpointDescription);
+        if (registration_factory->trackedFactory != NULL) {
+            registration_factory->trackedFactory->unregisterProxyService(registration_factory->trackedFactory->factory,
endpointDescription);
+        }
 		arrayList_removeElement(registration_factory->registrations, registration);
 		importRegistration_destroy(registration);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cc7d0912/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 cea9330..5e3ca72 100644
--- a/remote_services/topology_manager/private/src/topology_manager.c
+++ b/remote_services/topology_manager/private/src/topology_manager.c
@@ -664,14 +664,16 @@ celix_status_t topologyManager_removeExportedService(topology_manager_pt
manager
                 remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
                 array_list_pt exportRegistrations = hashMapEntry_getValue(entry);
 
-                for (int exportsIter = 0; exportsIter < arrayList_size(exportRegistrations);
exportsIter++) {
+                int size = arrayList_size(exportRegistrations);
+
+                for (int exportsIter = 0; exportsIter < size; exportsIter++) {
                     export_registration_pt export = arrayList_get(exportRegistrations, exportsIter);
                     topologyManager_notifyListenersEndpointRemoved(manager, rsa, export);
                     rsa->exportRegistration_close(rsa->admin, export);
                 }
 
                 hashMap_remove(exports, rsa);
-                arrayList_destroy(exportRegistrations);
+                //arrayList_destroy(exportRegistrations);
                 hashMapIterator_destroy(iter);
                 iter = hashMapIterator_create(exports);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/cc7d0912/remote_services/topology_manager/tms_tst/tms_tests.cpp
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/tms_tst/tms_tests.cpp b/remote_services/topology_manager/tms_tst/tms_tests.cpp
index 20a6c2e..b7db826 100644
--- a/remote_services/topology_manager/tms_tst/tms_tests.cpp
+++ b/remote_services/topology_manager/tms_tst/tms_tests.cpp
@@ -130,15 +130,23 @@ extern "C" {
 
         rc = bundleContext_ungetService(context, scopeServiceRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,scopeServiceRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         rc = bundleContext_ungetService(context, calcRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,calcRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         rc = bundleContext_ungetService(context, rsaRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,rsaRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         rc = bundleContext_ungetService(context, discRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,discRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         celixLauncher_stop(framework);
         celixLauncher_waitForShutdown(framework);
@@ -208,20 +216,25 @@ extern "C" {
     static void teardownFmImport(void) {
         int rc = 0;
 
-        rc = bundleContext_ungetService(context, scopeServiceRef, NULL);
+        rc = bundleContext_ungetService(context, rsaRef, NULL);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,rsaRef);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
-// rc = bundleContext_ungetService(context, calcRef, NULL);
-//        CHECK_EQUAL(CELIX_SUCCESS, rc);
-
-        rc = bundleContext_ungetService(context, rsaRef, NULL);
+        rc = bundleContext_ungetService(context, scopeServiceRef, NULL);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,scopeServiceRef);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         rc = bundleContext_ungetService(context, testRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,testRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         rc = bundleContext_ungetService(context, eplRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
+        rc = bundleContext_ungetServiceReference(context,eplRef);
+        CHECK_EQUAL(CELIX_SUCCESS, rc);
 
         celixLauncher_stop(framework);
         celixLauncher_waitForShutdown(framework);
@@ -379,7 +392,7 @@ extern "C" {
         discMock->getEPDescriptors(discMock->handle, &epList);
         // We export two services: Calculator and Calculator2, but only 1 has DFI bundle
info
         CHECK_EQUAL(1, arrayList_size(epList));
-        for (int i = 0; i < arrayList_size(epList); i++) {
+        for (unsigned int i = 0; i < arrayList_size(epList); i++) {
         	endpoint_description_pt ep = (endpoint_description_pt) arrayList_get(epList, i);
         	properties_pt props = ep->properties;
         	hash_map_entry_pt entry = hashMap_getEntry(props, (void*)"key2");
@@ -415,7 +428,7 @@ extern "C" {
         discMock->getEPDescriptors(discMock->handle, &epList);
         // We export two services: Calculator and Calculator2, but only 1 has DFI bundle
info
         CHECK_EQUAL(1, arrayList_size(epList));
-        for (int i = 0; i < arrayList_size(epList); i++) {
+        for (unsigned int i = 0; i < arrayList_size(epList); i++) {
         	endpoint_description_pt ep = (endpoint_description_pt) arrayList_get(epList, i);
         	properties_pt props = ep->properties;
         	hash_map_entry_pt entry = hashMap_getEntry(props, (void*)"key2");
@@ -439,7 +452,7 @@ extern "C" {
         discMock->getEPDescriptors(discMock->handle, &epList);
         // We export two services: Calculator and Calculator2, but only 1 has DFI bundle
info
         CHECK_EQUAL(1, arrayList_size(epList));
-        for (int i = 0; i < arrayList_size(epList); i++) {
+        for (unsigned int i = 0; i < arrayList_size(epList); i++) {
         	endpoint_description_pt ep = (endpoint_description_pt) arrayList_get(epList, i);
         	properties_pt props = ep->properties;
         	hash_map_entry_pt entry = hashMap_getEntry(props, (void *)"key2");
@@ -463,7 +476,7 @@ extern "C" {
         discMock->getEPDescriptors(discMock->handle, &epList);
         // We export two services: Calculator and Calculator2, but only 1 has DFI bundle
info
         CHECK_EQUAL(1, arrayList_size(epList));
-        for (int i = 0; i < arrayList_size(epList); i++) {
+        for (unsigned int i = 0; i < arrayList_size(epList); i++) {
         	endpoint_description_pt ep = (endpoint_description_pt) arrayList_get(epList, i);
         	properties_pt props = ep->properties;
         	hash_map_entry_pt entry = hashMap_getEntry(props, (void*)"zone");


Mime
View raw message