Return-Path: X-Original-To: apmail-celix-commits-archive@www.apache.org Delivered-To: apmail-celix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 93E2A9BB6 for ; Sat, 20 Dec 2014 16:37:17 +0000 (UTC) Received: (qmail 64556 invoked by uid 500); 20 Dec 2014 16:37:17 -0000 Delivered-To: apmail-celix-commits-archive@celix.apache.org Received: (qmail 64530 invoked by uid 500); 20 Dec 2014 16:37:17 -0000 Mailing-List: contact commits-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list commits@celix.apache.org Received: (qmail 64520 invoked by uid 99); 20 Dec 2014 16:37:17 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Dec 2014 16:37:17 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id E8428AC0947; Sat, 20 Dec 2014 16:37:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1647014 - in /celix/trunk/remote_services: remote_service_admin_http/private/src/import_registration_impl.c remote_service_admin_http/private/src/remote_service_admin_impl.c topology_manager/private/src/topology_manager.c Date: Sat, 20 Dec 2014 16:37:14 -0000 To: commits@celix.apache.org From: bpetri@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141220163716.E8428AC0947@hades.apache.org> Author: bpetri Date: Sat Dec 20 16:37:14 2014 New Revision: 1647014 URL: http://svn.apache.org/r1647014 Log: CELIX-190: remote services mem leak fixing... Modified: celix/trunk/remote_services/remote_service_admin_http/private/src/import_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_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=1647014&r1=1647013&r2=1647014&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 Sat Dec 20 16:37:14 2014 @@ -110,6 +110,7 @@ celix_status_t importRegistrationFactory free((*registration_factory)->serviceName); arrayList_destroy((*registration_factory)->registrations); + serviceTracker_destroy((*registration_factory)->proxyFactoryTracker); free(*registration_factory); } @@ -229,7 +230,8 @@ celix_status_t importRegistrationFactory // check whether factory is available if (((*registration_factory)->trackedFactory == NULL) && ((status = importRegistrationFactory_open(*registration_factory)) != CELIX_SUCCESS)) { logHelper_log((*registration_factory)->loghelper, OSGI_LOGSERVICE_ERROR, "remoteServiceAdmin_importService: cannot open registration_factory for %s.", serviceName); - serviceTracker_close((*registration_factory)->proxyFactoryTracker); + + importRegistrationFactory_close(*registration_factory); importRegistrationFactory_destroy(registration_factory); } } 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=1647014&r1=1647013&r2=1647014&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 Sat Dec 20 16:37:14 2014 @@ -213,7 +213,11 @@ celix_status_t remoteServiceAdmin_stop(r iter = hashMapIterator_create(admin->importedServices); while (hashMapIterator_hasNext(iter)) { - import_registration_factory_pt importFactory = hashMapIterator_nextValue(iter); + hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); + + char* service = hashMapEntry_getKey(entry); + import_registration_factory_pt importFactory = hashMapEntry_getValue(entry); + int i; for (i = 0; i < arrayList_size(importFactory->registrations); i++) { @@ -227,6 +231,10 @@ celix_status_t remoteServiceAdmin_stop(r serviceTracker_close(importFactory->proxyFactoryTracker); importRegistrationFactory_close(importFactory); + + hashMap_remove(admin->importedServices, service); + importRegistrationFactory_destroy(&importFactory); + } hashMapIterator_destroy(iter); celixThreadMutex_unlock(&admin->importedServicesLock); @@ -632,6 +640,7 @@ celix_status_t remoteServiceAdmin_remove importRegistrationFactory_close(registration_factory); hashMap_remove(admin->importedServices, endpointDescription->service); + importRegistrationFactory_destroy(®istration_factory); } } 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=1647014&r1=1647013&r2=1647014&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 Sat Dec 20 16:37:14 2014 @@ -169,6 +169,11 @@ celix_status_t topologyManager_rsaAdded( if (status == CELIX_SUCCESS) { hash_map_pt imports = hashMapEntry_getValue(entry); + + if (imports == NULL) { + imports = hashMap_create(NULL, NULL, NULL, NULL); + } + hashMap_put(imports, service, import); } } @@ -226,6 +231,7 @@ celix_status_t topologyManager_rsaRemove remote_service_admin_service_pt rsa = (remote_service_admin_service_pt) service; + status = celixThreadMutex_lock(&manager->exportedServicesLock); hash_map_iterator_pt iter = hashMapIterator_create(manager->exportedServices); @@ -350,6 +356,8 @@ celix_status_t topologyManager_addImport } } + arrayList_destroy(localRSAs); + status = celixThreadMutex_unlock(&manager->importedServicesLock); return status; @@ -384,6 +392,13 @@ celix_status_t topologyManager_removeImp } } hashMapIterator_destroy(importsIter); + + imports = hashMap_remove(manager->importedServices, ep); + + if (imports != NULL) { + hashMap_destroy(imports, false, false); + } + } } hashMapIterator_destroy(iter); @@ -462,9 +477,11 @@ celix_status_t topologyManager_removeExp } hashMapIterator_destroy(iter); } - exports = hashMap_remove(manager->exportedServices, reference); - if (exports != NULL) { - hashMap_destroy(exports, false, false); + + exports = hashMap_remove(manager->exportedServices, reference); + + if (exports != NULL) { + hashMap_destroy(exports, false, false); } status = celixThreadMutex_unlock(&manager->exportedServicesLock);