celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1628666 - in /celix/trunk: framework/private/src/ remote_services/remote_service_admin_http/private/src/ remote_services/remote_service_admin_shm/private/src/ remote_services/topology_manager/private/src/
Date Wed, 01 Oct 2014 09:52:21 GMT
Author: abroekhuis
Date: Wed Oct  1 09:52:20 2014
New Revision: 1628666

URL: http://svn.apache.org/r1628666
Log:
CELIX-151: Committed a fix for the shutdown issue. Also updated the RSA to directly uninstall
a bundle, uninstall does stop a bundle if needed.

Modified:
    celix/trunk/framework/private/src/framework.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/import_registration_impl.c
    celix/trunk/remote_services/remote_service_admin_shm/private/src/export_registration_impl.c
    celix/trunk/remote_services/remote_service_admin_shm/private/src/import_registration_impl.c
    celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/framework.c?rev=1628666&r1=1628665&r2=1628666&view=diff
==============================================================================
--- celix/trunk/framework/private/src/framework.c (original)
+++ celix/trunk/framework/private/src/framework.c Wed Oct  1 09:52:20 2014
@@ -798,6 +798,7 @@ celix_status_t fw_stopBundle(framework_p
     char *error = NULL;
 
 	status = CELIX_DO_IF(status, framework_acquireBundleLock(framework, bundle, OSGI_FRAMEWORK_BUNDLE_INSTALLED|OSGI_FRAMEWORK_BUNDLE_RESOLVED|OSGI_FRAMEWORK_BUNDLE_STARTING|OSGI_FRAMEWORK_BUNDLE_ACTIVE));
+	printf("Stop status: %d\n", status);
 
 	if (record) {
 	    status = CELIX_DO_IF(status, bundle_setPersistentStateInactive(bundle));
@@ -923,6 +924,7 @@ celix_status_t fw_uninstallBundle(framew
     status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
     status = CELIX_DO_IF(status, bundleArchive_getLocation(archive, &location));
     if (status == CELIX_SUCCESS) {
+        printf("Uninstall %s\n", location);
         // TODO sync issues?
         target = (bundle_pt) hashMap_remove(framework->installedBundleMap, location);
 
@@ -962,6 +964,7 @@ celix_status_t fw_uninstallBundle(framew
             if (refreshStatus != CELIX_SUCCESS) {
                 printf("Could not refresh bundle");
             } else {
+                printf("destroy bundle: %s %p\n", location, bundle);
                 status = CELIX_DO_IF(status, bundle_destroy(bundle));
             }
 
@@ -1841,10 +1844,12 @@ celix_status_t framework_acquireBundleLo
 			bundle_state_e state;
 			bundle_getState(bundle, &state);
 			if ((desiredStates & state) == 0) {
+			    printf("Lock failed - state %d\n", state);
 				status = CELIX_ILLEGAL_STATE;
 			} else {
 				if (bundle_lock(bundle, &locked)) {
 					if (!locked) {
+					    printf("Lock failed\n");
 						status = CELIX_ILLEGAL_STATE;
 					}
 				}
@@ -1966,30 +1971,49 @@ celix_status_t framework_waitForStop(fra
 
 static void *framework_shutdown(void *framework) {
 	framework_pt fw = (framework_pt) framework;
-	hash_map_values_pt values = NULL;
-    bundle_pt **installedBundleArray;
-    unsigned int size;
+//	hash_map_values_pt values = NULL;
+//    bundle_pt **installedBundleArray;
+//    unsigned int size;
 	int err;
-    int i;
+//    int i;
 
 	fw_log(fw->logger, OSGI_FRAMEWORK_LOG_INFO, "FRAMEWORK: Shutdown");
-    values = hashMapValues_create(fw->installedBundleMap);
-    hashMapValues_toArray(values, (void*) &installedBundleArray, &size);
 
-    for(i = 0; i < size; i++) {
-	    bundle_pt bundle = (bundle_pt) installedBundleArray[i];
-		bundle_state_e state;
-		bundle_getState(bundle, &state);
-		if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING) {
-			char *location;
-			bundle_archive_pt archive = NULL;
-
-			bundle_getArchive(bundle, &archive);
-			bundleArchive_getLocation(archive, &location);
-			fw_stopBundle(fw, bundle, 0);
-		}
+	hash_map_iterator_pt iter = hashMapIterator_create(fw->installedBundleMap);
+	bundle_pt bundle = NULL;
+	while ((bundle = hashMapIterator_nextValue(iter)) != NULL) {
+	    printf("Bundle: %p\n", bundle);
+//        bundle_pt bundle = (bundle_pt) installedBundleArray[i];
+        bundle_state_e state;
+        bundle_getState(bundle, &state);
+        if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING)
{
+            fw_stopBundle(fw, bundle, 0);
+            hashMapIterator_destroy(iter);
+            iter = hashMapIterator_create(fw->installedBundleMap);
+        }
 	}
 
+
+//    values = hashMapValues_create(fw->installedBundleMap);
+//    hashMapValues_toArray(values, (void*) &installedBundleArray, &size);
+//
+//    for(i = 0; i < size; i++) {
+//	    bundle_pt bundle = (bundle_pt) installedBundleArray[i];
+//		bundle_state_e state;
+//		bundle_getState(bundle, &state);
+//		if (state == OSGI_FRAMEWORK_BUNDLE_ACTIVE || state == OSGI_FRAMEWORK_BUNDLE_STARTING)
{
+//			char *location;
+//			bundle_archive_pt archive = NULL;
+//
+//			bundle_getArchive(bundle, &archive);
+//			bundleArchive_getLocation(archive, &location);
+//
+//
+//
+//			fw_stopBundle(fw, bundle, 0);
+//		}
+//	}
+
 	err = celixThreadMutex_lock(&fw->mutex);
 	if (err != 0) {
 		fw_log(fw->logger, OSGI_FRAMEWORK_LOG_ERROR,  "Error locking the framework, cannot exit
clean.");

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c?rev=1628666&r1=1628665&r2=1628666&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c
Wed Oct  1 09:52:20 2014
@@ -187,7 +187,6 @@ celix_status_t exportRegistration_close(
 
 	exportRegistration_stopTracking(registration);
 
-	bundle_stop(registration->bundle);
 	bundle_uninstall(registration->bundle);
 	remoteServiceAdmin_removeExportedService(registration);
 

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/import_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/import_registration_impl.c?rev=1628666&r1=1628665&r2=1628666&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/import_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/import_registration_impl.c
Wed Oct  1 09:52:20 2014
@@ -148,7 +148,6 @@ celix_status_t importRegistrationFactory
 	}
 
 	if (registration_factory->bundle != NULL) {
-		bundle_stop(registration_factory->bundle);
 		bundle_uninstall(registration_factory->bundle);
 	}
 

Modified: celix/trunk/remote_services/remote_service_admin_shm/private/src/export_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_shm/private/src/export_registration_impl.c?rev=1628666&r1=1628665&r2=1628666&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_shm/private/src/export_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_shm/private/src/export_registration_impl.c
Wed Oct  1 09:52:20 2014
@@ -184,7 +184,6 @@ celix_status_t exportRegistration_close(
 	celix_status_t status = CELIX_SUCCESS;
 
 	exportRegistration_stopTracking(registration);
-	bundle_stop(registration->bundle);
 	bundle_uninstall(registration->bundle);
 	remoteServiceAdmin_removeExportedService(registration);
 

Modified: celix/trunk/remote_services/remote_service_admin_shm/private/src/import_registration_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_shm/private/src/import_registration_impl.c?rev=1628666&r1=1628665&r2=1628666&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_shm/private/src/import_registration_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_shm/private/src/import_registration_impl.c
Wed Oct  1 09:52:20 2014
@@ -143,7 +143,6 @@ celix_status_t importRegistrationFactory
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (registration_factory->bundle != NULL) {
-		bundle_stop(registration_factory->bundle);
 		bundle_uninstall(registration_factory->bundle);
 	}
 

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=1628666&r1=1628665&r2=1628666&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 Wed Oct  1
09:52:20 2014
@@ -409,12 +409,8 @@ celix_status_t topologyManager_notifyLis
 	for (int eplIt = 0; eplIt < eplSize; eplIt++) {
 		service_reference_pt eplRef = arrayList_get(endpointListeners, eplIt);
 
-		service_registration_pt registration = NULL;
-		serviceReference_getServiceRegistration(eplRef, &registration);
-
-		properties_pt props = NULL;
-		serviceRegistration_getProperties(registration, &props);
-		char *scope = properties_get(props, (char *) OSGI_ENDPOINT_LISTENER_SCOPE);
+		char *scope = NULL;
+		serviceReference_getProperty(eplRef, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope);
 
 		endpoint_listener_pt epl = NULL;
 		status = bundleContext_getService(manager->context, eplRef, (void **) &epl);



Mime
View raw message