incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject svn commit: r1524033 - in /incubator/celix/trunk: framework/private/src/ framework/public/include/ remote_services/remote_service_admin/private/include/ remote_services/remote_service_admin/private/src/ remote_services/remote_service_admin/public/inclu...
Date Tue, 17 Sep 2013 13:21:15 GMT
Author: pnoltes
Date: Tue Sep 17 13:21:14 2013
New Revision: 1524033

URL: http://svn.apache.org/r1524033
Log:
CELIX-82: fixed segfault bug with respect to wrong service reference usage. 

Modified:
    incubator/celix/trunk/framework/private/src/service_reference.c
    incubator/celix/trunk/framework/public/include/service_reference.h
    incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
    incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
    incubator/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
    incubator/celix/trunk/remote_services/topology_manager/private/include/topology_manager.h
    incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
    incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: incubator/celix/trunk/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_reference.c?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_reference.c (original)
+++ incubator/celix/trunk/framework/private/src/service_reference.c Tue Sep 17 13:21:14 2013
@@ -78,6 +78,11 @@ celix_status_t serviceReference_invalida
 	return CELIX_SUCCESS;
 }
 
+celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool *result) {
+	(*result) = reference->registration != NULL;
+	return CELIX_SUCCESS;
+}
+
 bool serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester,
char * serviceName) {
 	bool allow = true;
 

Modified: incubator/celix/trunk/framework/public/include/service_reference.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/service_reference.h?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/service_reference.h (original)
+++ incubator/celix/trunk/framework/public/include/service_reference.h Tue Sep 17 13:21:14
2013
@@ -38,6 +38,7 @@ typedef struct serviceReference * servic
 celix_status_t serviceReference_create(apr_pool_t *pool, bundle_pt bundle, service_registration_pt
registration, service_reference_pt *reference);
 
 FRAMEWORK_EXPORT celix_status_t serviceReference_invalidate(service_reference_pt reference);
+FRAMEWORK_EXPORT celix_status_t serviceRefernce_isValid(service_reference_pt reference, bool
*result);
 
 FRAMEWORK_EXPORT celix_status_t serviceReference_getServiceRegistration(service_reference_pt
reference, service_registration_pt *registration);
 FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt reference,
bundle_pt *bundle);

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
Tue Sep 17 13:21:14 2013
@@ -58,7 +58,7 @@ struct remote_service_admin {
 celix_status_t remoteServiceAdmin_create(apr_pool_t *pool, bundle_context_pt context, remote_service_admin_pt
*admin);
 celix_status_t remoteServiceAdmin_stop(remote_service_admin_pt admin);
 
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, service_reference_pt
reference, properties_pt properties, array_list_pt *registrations);
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, char *serviceId,
properties_pt properties, array_list_pt *registrations);
 celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_pt admin, array_list_pt
*services);
 celix_status_t remoteServiceAdmin_getImportedEndpoints(remote_service_admin_pt admin, array_list_pt
*services);
 celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, endpoint_description_pt
endpoint, import_registration_pt *registration);

Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
Tue Sep 17 13:21:14 2013
@@ -69,7 +69,7 @@ celix_status_t remoteServiceAdmin_create
 		char *port = NULL;
 		bundleContext_getProperty(context, "RSA_PORT", &port);
 		if (port == NULL) {
-			(*admin)->port = DEFAULT_PORT;
+			(*admin)->port = (char *)DEFAULT_PORT;
 		} else {
 			(*admin)->port = apr_pstrdup(pool, port);
 		}
@@ -173,11 +173,32 @@ celix_status_t remoteServiceAdmin_handle
 	return CELIX_SUCCESS;
 }
 
-celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, service_reference_pt
reference, properties_pt properties, array_list_pt *registrations) {
+celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, char *serviceId,
properties_pt properties, array_list_pt *registrations) {
 	celix_status_t status = CELIX_SUCCESS;
 	arrayList_create(admin->pool, registrations);
-
+	array_list_pt references = NULL;
+	service_reference_pt reference = NULL;
 	service_registration_pt registration = NULL;
+	apr_pool_t *tmpPool = NULL;
+
+	apr_pool_create(&tmpPool, admin->pool);
+	if (tmpPool == NULL) {
+		return CELIX_ENOMEM;
+	} else {
+		char *filter = apr_pstrcat(admin->pool, "(", (char *)SERVICE_ID, "=", serviceId, ")",
NULL); /*FIXME memory leak*/
+		bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
+		apr_pool_destroy(tmpPool);
+		if (arrayList_size(references) >= 1) {
+			reference = arrayList_get(references, 0);
+		}
+	}
+
+	if (reference == NULL) {
+		printf("ERROR: expected a reference for service id %s\n", serviceId);
+		return CELIX_ILLEGAL_STATE;
+	}
+
+
 	serviceReference_getServiceRegistration(reference, &registration);
 	properties_pt serviceProperties = NULL;
 	serviceRegistration_getProperties(registration, &serviceProperties);

Modified: incubator/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
(original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/public/include/remote_service_admin.h
Tue Sep 17 13:21:14 2013
@@ -40,7 +40,7 @@ typedef struct remote_service_admin *rem
 
 struct remote_service_admin_service {
 	remote_service_admin_pt admin;
-	celix_status_t (*exportService)(remote_service_admin_pt admin, service_reference_pt reference,
properties_pt properties, array_list_pt *registrations);
+	celix_status_t (*exportService)(remote_service_admin_pt admin, char *serviceId, properties_pt
properties, array_list_pt *registrations);
 	celix_status_t (*getExportedServices)(remote_service_admin_pt admin, array_list_pt *services);
 	celix_status_t (*getImportedEndpoints)(remote_service_admin_pt admin, array_list_pt *services);
 	celix_status_t (*importService)(remote_service_admin_pt admin, endpoint_description_pt endpoint,
import_registration_pt *registration);

Modified: incubator/celix/trunk/remote_services/topology_manager/private/include/topology_manager.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/include/topology_manager.h?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/include/topology_manager.h
(original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/include/topology_manager.h
Tue Sep 17 13:21:14 2013
@@ -46,8 +46,8 @@ celix_status_t topologyManager_endpointA
 celix_status_t topologyManager_endpointRemoved(void *handle, endpoint_description_pt endpoint,
char *machtedFilter);
 
 celix_status_t topologyManager_importService(topology_manager_pt manager, endpoint_description_pt
endpoint);
-celix_status_t topologyManager_exportService(topology_manager_pt manager, service_reference_pt
reference);
-celix_status_t topologyManager_removeService(topology_manager_pt manager, service_reference_pt
reference);
+celix_status_t topologyManager_exportService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId);
+celix_status_t topologyManager_removeService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId);
 
 celix_status_t topologyManager_listenerAdded(void *handle, array_list_pt listeners);
 celix_status_t topologyManager_listenerRemoved(void *handle, array_list_pt listeners);

Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c Tue Sep
17 13:21:14 2013
@@ -151,7 +151,7 @@ celix_status_t bundleActivator_start(voi
 
 	bundleContext_registerService(context, (char *) listener_hook_service_name, hook, NULL,
&activator->hook);
 
-	bundleContext_addServiceListener(context, activator->serviceListener, NULL);
+	bundleContext_addServiceListener(context, activator->serviceListener, "(service.exported.interfaces=*)");
 	serviceTracker_open(activator->remoteServiceAdminTracker);
 
 	return status;

Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1524033&r1=1524032&r2=1524033&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
(original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
Tue Sep 17 13:21:14 2013
@@ -118,23 +118,25 @@ celix_status_t topologyManager_rsaRemove
 celix_status_t topologyManager_serviceChanged(void *listener, service_event_pt event) {
 	celix_status_t status = CELIX_SUCCESS;
 	service_listener_pt listen = listener;
+
 	topology_manager_pt manager = listen->handle;
 	service_registration_pt registration = NULL;
+	printf("found event reference %p\n", event->reference);
 	serviceReference_getServiceRegistration(event->reference, &registration);
 	properties_pt props = NULL;
 	serviceRegistration_getProperties(registration, &props);
 	char *name = properties_get(props, (char *) OBJECTCLASS);
 	char *export = properties_get(props, (char *) SERVICE_EXPORTED_INTERFACES);
+	char *serviceId = properties_get(props, (char *)SERVICE_ID);
 
 	if (event->type == SERVICE_EVENT_REGISTERED) {
 		if (export != NULL) {
-			printf("TOPOLOGY_MANAGER: Service registered: %s\n", name);
-			status = topologyManager_exportService(manager, event->reference);
+			status = topologyManager_exportService(manager, event->reference, serviceId);
 		}
 	} else if (event->type == SERVICE_EVENT_UNREGISTERING) {
 		//if (export != NULL) {
 			printf("TOPOLOGY_MANAGER: Service unregistering: %s\n", name);
-			status = topologyManager_removeService(manager, event->reference);
+			status = topologyManager_removeService(manager, event->reference, serviceId);
 		//}
 	}
 
@@ -170,7 +172,7 @@ celix_status_t topologyManager_endpointR
 	return status;
 }
 
-celix_status_t topologyManager_exportService(topology_manager_pt manager, service_reference_pt
reference) {
+celix_status_t topologyManager_exportService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId) {
 	celix_status_t status = CELIX_SUCCESS;
 	hash_map_pt exports = hashMap_create(NULL, NULL, NULL, NULL);
 
@@ -195,7 +197,7 @@ celix_status_t topologyManager_exportSer
 			remote_service_admin_service_pt rsa = arrayList_get(manager->rsaList, iter);
 
 			array_list_pt endpoints = NULL;
-			status = rsa->exportService(rsa->admin, reference, NULL, &endpoints);
+			status = rsa->exportService(rsa->admin, serviceId, NULL, &endpoints);
 			if (status == CELIX_SUCCESS) {
 				hashMap_put(exports, rsa, endpoints);
 				status = topologyManager_notifyListeners(manager, rsa, endpoints);
@@ -275,7 +277,7 @@ celix_status_t topologyManager_importSer
 	return status;
 }
 
-celix_status_t topologyManager_removeService(topology_manager_pt manager, service_reference_pt
reference) {
+celix_status_t topologyManager_removeService(topology_manager_pt manager, service_reference_pt
reference, char *serviceId) {
 	celix_status_t status = CELIX_SUCCESS;
 
 	service_registration_pt registration = NULL;



Mime
View raw message