celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1645045 - in /celix/trunk/remote_services: discovery/private/src/discovery_activator.c discovery/private/src/endpoint_discovery_poller.c topology_manager/private/src/activator.c
Date Fri, 12 Dec 2014 19:31:27 GMT
Author: bpetri
Date: Fri Dec 12 19:31:27 2014
New Revision: 1645045

URL: http://svn.apache.org/r1645045
Log:
CELIX-190: fixed minor leaks

Modified:
    celix/trunk/remote_services/discovery/private/src/discovery_activator.c
    celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
    celix/trunk/remote_services/topology_manager/private/src/activator.c

Modified: celix/trunk/remote_services/discovery/private/src/discovery_activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/discovery_activator.c?rev=1645045&r1=1645044&r2=1645045&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/discovery_activator.c (original)
+++ celix/trunk/remote_services/discovery/private/src/discovery_activator.c Fri Dec 12 19:31:27
2014
@@ -44,6 +44,7 @@ struct activator {
 	log_helper_pt loghelper;
 
 	service_tracker_pt endpointListenerTracker;
+	endpoint_listener_pt endpointListener;
 	service_registration_pt endpointListenerService;
 };
 
@@ -78,6 +79,7 @@ celix_status_t bundleActivator_create(bu
 
 	activator->context = context;
 	activator->endpointListenerTracker = NULL;
+	activator->endpointListener = NULL;
 	activator->endpointListenerService = NULL;
 
 	logHelper_create(context, &activator->loghelper);
@@ -114,6 +116,7 @@ celix_status_t bundleActivator_start(voi
 	logHelper_log(activator->loghelper, OSGI_LOGSERVICE_DEBUG, "using scope %s.", scope);
 
 	endpoint_listener_pt endpointListener = malloc(sizeof(struct endpoint_listener));
+
 	if (!endpointListener) {
 		return CELIX_ENOMEM;
 	}
@@ -128,6 +131,8 @@ celix_status_t bundleActivator_start(voi
 
 	status = bundleContext_registerService(context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE,
endpointListener, props, &activator->endpointListenerService);
 
+	activator->endpointListener = endpointListener;
+
 	if (status == CELIX_SUCCESS) {
 		status = serviceTracker_open(activator->endpointListenerTracker);
 	}
@@ -145,10 +150,10 @@ celix_status_t bundleActivator_start(voi
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
-
 	status = serviceTracker_close(activator->endpointListenerTracker);
 
 	status = serviceRegistration_unregister(activator->endpointListenerService);
+	free(activator->endpointListener);
 
 	status = discovery_stop(activator->discovery);
 

Modified: celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c?rev=1645045&r1=1645044&r2=1645045&view=diff
==============================================================================
--- celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c (original)
+++ celix/trunk/remote_services/discovery/private/src/endpoint_discovery_poller.c Fri Dec
12 19:31:27 2014
@@ -190,6 +190,9 @@ celix_status_t endpointDiscoveryPoller_r
         return CELIX_BUNDLE_EXCEPTION;
     }
 
+    hash_map_entry_pt entry  = hashMap_getEntry(poller->entries, url);
+    char* origKey = hashMapEntry_getKey(entry);
+
     array_list_pt entries = hashMap_remove(poller->entries, url);
 
 	for (int i = 0; i < arrayList_size(entries); i++) {
@@ -201,6 +204,8 @@ celix_status_t endpointDiscoveryPoller_r
 		arrayList_destroy(entries);
 	}
 
+
+	free(origKey);
 	status = celixThreadMutex_unlock(&poller->pollerLock);
 
     return status;

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=1645045&r1=1645044&r2=1645045&view=diff
==============================================================================
--- celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ celix/trunk/remote_services/topology_manager/private/src/activator.c Fri Dec 12 19:31:27
2014
@@ -45,7 +45,10 @@ struct activator {
 	service_tracker_pt remoteServiceAdminTracker;
 	service_listener_pt serviceListener;
 
+	endpoint_listener_pt endpointListener;
 	service_registration_pt endpointListenerService;
+
+	listener_hook_service_pt hookService;
 	service_registration_pt hook;
 };
 
@@ -120,6 +123,7 @@ celix_status_t bundleActivator_start(voi
 	endpointListener->handle = activator->manager;
 	endpointListener->endpointAdded = topologyManager_addImportedService;
 	endpointListener->endpointRemoved = topologyManager_removeImportedService;
+	activator->endpointListener = endpointListener;
 
 	char *uuid = NULL;
 	status = bundleContext_getProperty(activator->context, (char *)OSGI_FRAMEWORK_FRAMEWORK_UUID,
&uuid);
@@ -146,12 +150,13 @@ celix_status_t bundleActivator_start(voi
 
 	bundleContext_registerService(context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE, endpointListener,
props, &activator->endpointListenerService);
 
-	listener_hook_service_pt hook = malloc(sizeof(*hook));
-	hook->handle = activator->manager;
-	hook->added = topologyManager_listenerAdded;
-	hook->removed = topologyManager_listenerRemoved;
+	listener_hook_service_pt hookService = malloc(sizeof(*hookService));
+	hookService->handle = activator->manager;
+	hookService->added = topologyManager_listenerAdded;
+	hookService->removed = topologyManager_listenerRemoved;
+	activator->hookService = hookService;
 
-	bundleContext_registerService(context, (char *) OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME,
hook, NULL, &activator->hook);
+	bundleContext_registerService(context, (char *) OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME,
hookService, NULL, &activator->hook);
 
 	bundleContext_addServiceListener(context, activator->serviceListener, "(service.exported.interfaces=*)");
 	serviceTracker_open(activator->remoteServiceAdminTracker);
@@ -179,9 +184,13 @@ celix_status_t bundleActivator_stop(void
 	serviceTracker_destroy(activator->remoteServiceAdminTracker);
 
 	bundleContext_removeServiceListener(context, activator->serviceListener);
+	free(activator->serviceListener);
 
 	serviceRegistration_unregister(activator->hook);
+	free(activator->hookService);
+
 	serviceRegistration_unregister(activator->endpointListenerService);
+	free(activator->endpointListener);
 
 	return status;
 }



Mime
View raw message