celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject svn commit: r1645863 - in /celix/trunk/remote_services: remote_service_admin/private/include/ remote_service_admin_http/private/src/ topology_manager/private/src/
Date Tue, 16 Dec 2014 07:08:37 GMT
Author: bpetri
Date: Tue Dec 16 07:08:37 2014
New Revision: 1645863

URL: http://svn.apache.org/r1645863
Log:
CELIX-190: fixed some memory leaks in exportRegistration

Modified:
    celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
    celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
    celix/trunk/remote_services/remote_service_admin_http/private/src/export_registration_impl.c
    celix/trunk/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
    celix/trunk/remote_services/topology_manager/private/src/topology_manager.c

Modified: celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h?rev=1645863&r1=1645862&r2=1645863&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/include/export_registration_impl.h
Tue Dec 16 07:08:37 2014
@@ -52,6 +52,7 @@ struct export_registration {
 };
 
 celix_status_t exportRegistration_create(apr_pool_t *pool, service_reference_pt reference,
endpoint_description_pt endpoint, remote_service_admin_pt rsa, bundle_context_pt context,
export_registration_pt *registration);
+celix_status_t exportRegistration_destroy(export_registration_pt *registration);
 celix_status_t exportRegistration_open(export_registration_pt registration);
 celix_status_t exportRegistration_close(export_registration_pt registration);
 celix_status_t exportRegistration_getException(export_registration_pt registration);

Modified: celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
URL: http://svn.apache.org/viewvc/celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h?rev=1645863&r1=1645862&r2=1645863&view=diff
==============================================================================
--- celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
(original)
+++ celix/trunk/remote_services/remote_service_admin/private/include/remote_service_admin_impl.h
Tue Dec 16 07:08:37 2014
@@ -61,4 +61,6 @@ celix_status_t exportReference_getExport
 celix_status_t importReference_getImportedEndpoint(import_reference_pt reference);
 celix_status_t importReference_getImportedService(import_reference_pt reference);
 
+celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_description_pt *description);
+
 #endif /* REMOTE_SERVICE_ADMIN_IMPL_H_ */

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=1645863&r1=1645862&r2=1645863&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
Tue Dec 16 07:08:37 2014
@@ -50,7 +50,7 @@ celix_status_t exportRegistration_create
 	apr_pool_t *mypool = NULL;
 	apr_pool_create(&mypool, pool);
 
-	*registration = apr_palloc(mypool, sizeof(**registration));
+	*registration = calloc(1, sizeof(**registration));
 	if (!*registration) {
 		status = CELIX_ENOMEM;
 	} else {
@@ -71,6 +71,14 @@ celix_status_t exportRegistration_create
 	return status;
 }
 
+celix_status_t exportRegistration_destroy(export_registration_pt *registration) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	remoteServiceAdmin_destroyEndpointDescription(&(*registration)->endpointDescription);
+	free(*registration);
+
+	return status;
+}
 
 celix_status_t exportRegistration_startTracking(export_registration_pt registration) {
 	celix_status_t status = CELIX_SUCCESS;
@@ -207,6 +215,8 @@ celix_status_t exportRegistration_close(
 	logHelper_stop(registration->loghelper);
 	logHelper_destroy(&registration->loghelper);
 
+	exportRegistration_destroy(&registration);
+
 	return status;
 }
 

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=1645863&r1=1645862&r2=1645863&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
Tue Dec 16 07:08:37 2014
@@ -430,6 +430,7 @@ celix_status_t remoteServiceAdmin_remove
     celixThreadMutex_lock(&admin->exportedServicesLock);
 
     hashMap_remove(admin->exportedServices, registration->reference);
+
     celixThreadMutex_unlock(&admin->exportedServicesLock);
 
     return status;
@@ -516,10 +517,7 @@ celix_status_t remoteServiceAdmin_create
 		properties_pt endpointProperties, char *interface, endpoint_description_pt *description)
{
 	celix_status_t status = CELIX_SUCCESS;
 
-	apr_pool_t *childPool = NULL;
-	apr_pool_create(&childPool, admin->pool); //TODO pool should be destroyed after when
endpoint is removed
-
-	*description = apr_palloc(childPool, sizeof(*description));
+	*description = calloc(1, sizeof(**description));
 	if (!*description) {
 		status = CELIX_ENOMEM;
 	} else {
@@ -535,6 +533,18 @@ celix_status_t remoteServiceAdmin_create
 	return status;
 }
 
+
+celix_status_t remoteServiceAdmin_destroyEndpointDescription(endpoint_description_pt *description)
+{
+	celix_status_t status = CELIX_SUCCESS;
+
+	properties_destroy((*description)->properties);
+	free(*description);
+
+	return status;
+}
+
+
 celix_status_t remoteServiceAdmin_getExportedServices(remote_service_admin_pt admin, array_list_pt
*services) {
 	celix_status_t status = CELIX_SUCCESS;
 	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=1645863&r1=1645862&r2=1645863&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 Tue Dec 16
07:08:37 2014
@@ -234,8 +234,8 @@ celix_status_t topologyManager_rsaRemove
         if (exports_list != NULL) {
             for (exportsIter = 0; exportsIter < arrayList_size(exports_list); exportsIter++)
{
                 export_registration_pt export = arrayList_get(exports_list, exportsIter);
-                rsa->exportRegistration_close(export);
                 topologyManager_notifyListenersEndpointRemoved(manager, rsa, export);
+                rsa->exportRegistration_close(export);
             }
 
             arrayList_destroy(exports_list);
@@ -432,9 +432,8 @@ celix_status_t topologyManager_removeExp
 
 			for (int exportsIter = 0; exportsIter < arrayList_size(exportRegistrations); exportsIter++)
{
 				export_registration_pt export = arrayList_get(exportRegistrations, exportsIter);
-				rsa->exportRegistration_close(export);
-
 				topologyManager_notifyListenersEndpointRemoved(manager, rsa, export);
+				rsa->exportRegistration_close(export);
 			}
 			arrayList_destroy(exportRegistrations);
 			exportRegistrations = NULL;



Mime
View raw message