celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1626693 - in /celix/trunk: framework/private/src/ remote_services/remote_service_admin/ remote_services/remote_service_admin_http/private/src/ remote_services/topology_manager/private/src/ shell/private/src/
Date Mon, 22 Sep 2014 08:18:27 GMT
Author: abroekhuis
Date: Mon Sep 22 08:18:26 2014
New Revision: 1626693

URL: http://svn.apache.org/r1626693
Log:
Applied several fixes to improve stability.

Modified:
    celix/trunk/framework/private/src/bundle_archive.c
    celix/trunk/framework/private/src/service_tracker.c
    celix/trunk/remote_services/remote_service_admin/CMakeLists.txt
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
    celix/trunk/remote_services/topology_manager/private/src/activator.c
    celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
    celix/trunk/shell/private/src/shell.c

Modified: celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/bundle_archive.c?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/framework/private/src/bundle_archive.c (original)
+++ celix/trunk/framework/private/src/bundle_archive.c Mon Sep 22 08:18:26 2014
@@ -120,9 +120,14 @@ celix_status_t bundleArchive_create(fram
                 archive->logger = logger;
                 time(&archive->lastModified);
 
-                bundleArchive_initialize(archive);
+                status = bundleArchive_initialize(archive);
+                if (status == CELIX_SUCCESS) {
+                    status = bundleArchive_revise(archive, location, inputFile);
 
-                bundleArchive_revise(archive, location, inputFile);
+                    if (status != CELIX_SUCCESS) {
+                        bundleArchive_closeAndDelete(archive);
+                    }
+                }
 
                 *bundle_archive = archive;
             }
@@ -188,7 +193,7 @@ celix_status_t bundleArchive_recreate(ch
 		} else {
 		    struct dirent *dent;
             long idx = 0;
-            char *location;
+            char *location = NULL;
 
             while ((dent = readdir(archive->archiveRootDir)) != NULL) {
                 if (dent->d_type == DT_DIR && (strncmp(dent->d_name, "version",
7) == 0)) {
@@ -198,7 +203,9 @@ celix_status_t bundleArchive_recreate(ch
 
             status = CELIX_DO_IF(status, bundleArchive_getRevisionLocation(archive, 0, &location));
             status = CELIX_DO_IF(status, bundleArchive_reviseInternal(archive, true, idx,
location, NULL));
-            free(location);
+            if (location) {
+                free(location);
+            }
             if (status == CELIX_SUCCESS) {
                 *bundle_archive = archive;
             }

Modified: celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/service_tracker.c?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/framework/private/src/service_tracker.c (original)
+++ celix/trunk/framework/private/src/service_tracker.c Mon Sep 22 08:18:26 2014
@@ -81,6 +81,9 @@ celix_status_t serviceTracker_destroy(se
 	if (tracker->listener != NULL) {
 		bundleContext_removeServiceListener(tracker->context, tracker->listener);
 	}
+	if (tracker->customizer != NULL) {
+	    serviceTrackerCustomizer_destroy(tracker->customizer);
+	}
 	arrayList_destroy(tracker->tracked);
 
 	return CELIX_SUCCESS;
@@ -286,10 +289,10 @@ static celix_status_t  serviceTracker_ad
 			if (status == CELIX_SUCCESS) {
 				if (function != NULL) {
 					status = function(handle, reference, service);
+				} else {
+                    status = bundleContext_getService(tracker->context, reference, service);
 				}
 			}
-		} else {
-			status = bundleContext_getService(tracker->context, reference, service);
 		}
 	} else {
 		status = bundleContext_getService(tracker->context, reference, service);

Modified: celix/trunk/remote_services/remote_service_admin/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/CMakeLists.txt?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/CMakeLists.txt (original)
+++ celix/trunk/remote_services/remote_service_admin/CMakeLists.txt Mon Sep 22 08:18:26 2014
@@ -25,6 +25,7 @@ install (FILES 
         public/include/remote_endpoint.h
         public/include/remote_proxy.h
         public/include/remote_service_admin.h
+        public/include/endpoint_description.h
     DESTINATION 
         include/celix/remote_service_admin 
     COMPONENT 

Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
(original)
+++ celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
Mon Sep 22 08:18:26 2014
@@ -316,8 +316,8 @@ celix_status_t remoteServiceAdmin_remove
     remote_service_admin_pt admin = registration->rsa;
     array_list_pt registrations = NULL;
 
+    printf("Remote export %p\n", registration->reference);
     registrations = hashMap_remove(admin->exportedServices, registration->reference);
-    // Registrations are allocated on the RSA pool, so there is a "leak" here. Removed services
still consume memory
 
     return CELIX_SUCCESS;
 }
@@ -445,8 +445,10 @@ celix_status_t remoteServiceAdmin_import
 	// check whether we already have a registration_factory
 	if (registration_factory == NULL)
 	{
-		importRegistrationFactory_install(admin->pool, endpointDescription->service, admin->context,
&registration_factory);
-		hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
+		status = importRegistrationFactory_install(admin->pool, endpointDescription->service,
admin->context, &registration_factory);
+		if (status == CELIX_SUCCESS) {
+		    hashMap_put(admin->importedServices, endpointDescription->service, registration_factory);
+		}
 	}
 
 	 // factory available

Modified: celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/activator.c Mon Sep 22 08:18:26
2014
@@ -155,6 +155,23 @@ celix_status_t bundleActivator_start(voi
 	bundleContext_addServiceListener(context, activator->serviceListener, "(service.exported.interfaces=*)");
 	serviceTracker_open(activator->remoteServiceAdminTracker);
 
+	array_list_pt references = NULL;
+	bundleContext_getServiceReferences(context, NULL, "(service.exported.interfaces=*)", &references);
+	int i;
+	for (i = 0; i < arrayList_size(references); i++) {
+	    service_reference_pt reference = arrayList_get(references, i);
+
+	    service_registration_pt registration = NULL;
+        serviceReference_getServiceRegistration(reference, &registration);
+	    properties_pt props = NULL;
+        serviceRegistration_getProperties(registration, &props);
+        char *serviceId = properties_get(props, (char *)OSGI_FRAMEWORK_SERVICE_ID);
+
+	    status = topologyManager_addExportedService(activator->manager, reference, serviceId);
+	}
+
+
+
 	return status;
 }
 

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=1626693&r1=1626692&r2=1626693&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 Mon Sep 22
08:18:26 2014
@@ -291,24 +291,31 @@ celix_status_t topologyManager_removeImp
 
 	status = celixThreadMutex_lock(&manager->importedServicesLock);
 
-	if (hashMap_containsKey(manager->importedServices, endpoint)) {
-		hash_map_pt imports = hashMap_get(manager->importedServices, endpoint);
-		hash_map_iterator_pt iter = hashMapIterator_create(imports);
+	hash_map_iterator_pt 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);
+
+	    if (strcmp(endpoint->id, ep->id) == 0) {
+	        hash_map_iterator_pt importsIter = hashMapIterator_create(imports);
+
+            while (hashMapIterator_hasNext(importsIter)) {
+                hash_map_entry_pt entry = hashMapIterator_nextEntry(importsIter);
+
+                remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
+                import_registration_pt import = hashMapEntry_getValue(entry);
+
+                status = rsa->importRegistration_close(rsa->admin, import);
+                if (status == CELIX_SUCCESS) {
+                    hashMap_remove(imports, rsa);
+                }
+            }
 
-		while (hashMapIterator_hasNext(iter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-
-			remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
-			import_registration_pt import = hashMapEntry_getValue(entry);
-
-			status = rsa->importRegistration_close(rsa->admin, import);
-			if (status == CELIX_SUCCESS) {
-				hashMap_remove(imports, rsa);
-			}
-		}
-
-		hashMapIterator_destroy(iter);
+            hashMapIterator_destroy(importsIter);
+	    }
 	}
+	hashMapIterator_destroy(iter);
 
 	status = celixThreadMutex_unlock(&manager->importedServicesLock);
 

Modified: celix/trunk/shell/private/src/shell.c
URL: http://svn.apache.org/viewvc/celix/trunk/shell/private/src/shell.c?rev=1626693&r1=1626692&r2=1626693&view=diff
==============================================================================
--- celix/trunk/shell/private/src/shell.c (original)
+++ celix/trunk/shell/private/src/shell.c Mon Sep 22 08:18:26 2014
@@ -236,6 +236,15 @@ celix_status_t bundleActivator_start(voi
 	    listener->serviceChanged = (void *) shell_serviceChanged;
 	    status = bundleContext_addServiceListener(context, listener, "(objectClass=commandService)");
 
+	    array_list_pt references = NULL;
+	    status = bundleContext_getServiceReferences(context, "commandService", NULL, &references);
+	    if (status == CELIX_SUCCESS) {
+	        int i = 0;
+	        for (i = 0; i < arrayList_size(references); i++) {
+	            shell_addCommand(activator->shell, arrayList_get(references, i));
+	        }
+	    }
+
 	    if (status == CELIX_SUCCESS) {
 	        activator->psCmd = psCommand_create(context);
 	        shell_createCommandService(activator->pool, activator->psCmd, &activator->psCmdSrv);



Mime
View raw message