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 945101791A for ; Wed, 7 Oct 2015 12:45:49 +0000 (UTC) Received: (qmail 93632 invoked by uid 500); 7 Oct 2015 12:45:43 -0000 Delivered-To: apmail-celix-commits-archive@celix.apache.org Received: (qmail 93579 invoked by uid 500); 7 Oct 2015 12:45:43 -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 93141 invoked by uid 99); 7 Oct 2015 12:45:42 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2015 12:45:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 44B62E0B65; Wed, 7 Oct 2015 12:45:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: pnoltes@apache.org To: commits@celix.apache.org Date: Wed, 07 Oct 2015 12:45:59 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [19/20] celix git commit: CELIX-190: fixed some remote services leaks/race-conditions CELIX-190: fixed some remote services leaks/race-conditions Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/cec955da Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/cec955da Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/cec955da Branch: refs/heads/feature/CELIX-237_rsa-ffi Commit: cec955da8b17d6c0f9ae9353223e34dda7fa50fe Parents: 3975102 Author: Bjoern Petri Authored: Wed Oct 7 12:49:34 2015 +0200 Committer: Bjoern Petri Committed: Wed Oct 7 12:49:34 2015 +0200 ---------------------------------------------------------------------- framework/private/src/service_registration.c | 6 +++++- launcher/private/src/launcher.c | 5 ++++- .../discovery/private/src/endpoint_discovery_poller.c | 2 +- .../discovery_etcd/private/src/discovery_impl.c | 1 - .../discovery_etcd/private/src/etcd_watcher.c | 11 +++++++++-- .../private/src/import_registration_impl.c | 4 +++- .../private/src/remote_proxy_factory_impl.c | 6 ++++++ remote_services/topology_manager/private/src/activator.c | 8 ++++---- 8 files changed, 32 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/framework/private/src/service_registration.c ---------------------------------------------------------------------- diff --git a/framework/private/src/service_registration.c b/framework/private/src/service_registration.c index 8e84d1a..cac87ee 100644 --- a/framework/private/src/service_registration.c +++ b/framework/private/src/service_registration.c @@ -109,7 +109,11 @@ static celix_status_t serviceRegistration_initializeProperties(service_registrat sprintf(sId, "%ld", registration->serviceId); properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_ID, sId); - properties_set(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS, registration->className); + + if (properties_get(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS) == NULL) { + properties_set(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS, registration->className); + } + free(sId); return CELIX_SUCCESS; http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/launcher/private/src/launcher.c ---------------------------------------------------------------------- diff --git a/launcher/private/src/launcher.c b/launcher/private/src/launcher.c index f334057..2da85bd 100644 --- a/launcher/private/src/launcher.c +++ b/launcher/private/src/launcher.c @@ -165,10 +165,13 @@ int main(int argc, char *argv[]) { framework_waitForStop(framework); framework_destroy(framework); - properties_destroy(config); } } + if (config != NULL) { + properties_destroy(config); + } + if (status != CELIX_SUCCESS) { printf("Problem creating framework\n"); } http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/discovery/private/src/endpoint_discovery_poller.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery/private/src/endpoint_discovery_poller.c b/remote_services/discovery/private/src/endpoint_discovery_poller.c index ac819c5..631f063 100644 --- a/remote_services/discovery/private/src/endpoint_discovery_poller.c +++ b/remote_services/discovery/private/src/endpoint_discovery_poller.c @@ -90,7 +90,7 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_con char *save_ptr = NULL; char* tok = strtok_r(endpoints, sep, &save_ptr); while (tok) { - endpointDiscoveryPoller_addDiscoveryEndpoint(*poller, strdup(utils_stringTrim(tok))); + endpointDiscoveryPoller_addDiscoveryEndpoint(*poller, utils_stringTrim(tok)); tok = strtok_r(NULL, sep, &save_ptr); } // Clean up after ourselves... http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/discovery_etcd/private/src/discovery_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery_etcd/private/src/discovery_impl.c b/remote_services/discovery_etcd/private/src/discovery_impl.c index b8d7d5c..00ab9a6 100644 --- a/remote_services/discovery_etcd/private/src/discovery_impl.c +++ b/remote_services/discovery_etcd/private/src/discovery_impl.c @@ -159,7 +159,6 @@ celix_status_t discovery_stop(discovery_pt discovery) { if (status != CELIX_SUCCESS) { return CELIX_BUNDLE_EXCEPTION; } - hash_map_iterator_pt iter; celixThreadMutex_lock(&discovery->discoveredServicesMutex); http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/discovery_etcd/private/src/etcd_watcher.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery_etcd/private/src/etcd_watcher.c b/remote_services/discovery_etcd/private/src/etcd_watcher.c index c54fcdc..b9b3ef8 100644 --- a/remote_services/discovery_etcd/private/src/etcd_watcher.c +++ b/remote_services/discovery_etcd/private/src/etcd_watcher.c @@ -224,9 +224,14 @@ static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key celix_status_t status = CELIX_BUNDLE_EXCEPTION; endpoint_discovery_poller_pt poller = watcher->discovery->poller; - if (hashMap_containsKey(watcher->entries, key)) { + hash_map_entry_pt entry = hashMap_getEntry(watcher->entries, key); - hashMap_remove(watcher->entries, key); + if (entry != NULL) { + hashMap_removeEntryForKey(watcher->entries, key); + + free(hashMapEntry_getKey(entry)); + free(hashMapEntry_getValue(entry)); + free(entry); // check if there is another entry with the same value hash_map_iterator_pt iter = hashMapIterator_create(watcher->entries); @@ -237,6 +242,8 @@ static celix_status_t etcdWatcher_removeEntry(etcd_watcher_pt watcher, char* key valueFound++; } + hashMapIterator_destroy(iter); + if (valueFound == 0) status = endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, value); http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/remote_service_admin/private/src/import_registration_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin/private/src/import_registration_impl.c b/remote_services/remote_service_admin/private/src/import_registration_impl.c index ecf6e09..606b897 100644 --- a/remote_services/remote_service_admin/private/src/import_registration_impl.c +++ b/remote_services/remote_service_admin/private/src/import_registration_impl.c @@ -40,7 +40,7 @@ celix_status_t importRegistration_proxyFactoryAdded(void * handle, service_refer celix_status_t importRegistration_proxyFactoryModified(void * handle, service_reference_pt reference, void *service); celix_status_t importRegistration_proxyFactoryRemoved(void * handle, service_reference_pt reference, void *service); -celix_status_t importRegistration_create(endpoint_description_pt endpoint, remote_service_admin_pt rsa, sendToHandle sendToCallback, bundle_context_pt context, import_registration_pt *registration) { +celix_status_t importRegistration_create(endpoint_description_pt endpoint, remote_service_admin_pt rsa, sendToHandle sendToCallback, bundle_context_pt context, import_registration_pt *registration) { celix_status_t status = CELIX_SUCCESS; *registration = calloc(1, sizeof(**registration)); @@ -61,6 +61,8 @@ celix_status_t importRegistration_create(endpoint_description_pt endpoint, remot celix_status_t importRegistration_destroy(import_registration_pt registration) { + free(registration); + return CELIX_SUCCESS; } http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c index 96e7557..54d7704 100644 --- a/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c +++ b/remote_services/remote_service_admin/private/src/remote_proxy_factory_impl.c @@ -173,13 +173,19 @@ static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_facto if (status == CELIX_SUCCESS) { properties_set(proxy_instance_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service); + + + + hash_map_iterator_pt iter = hashMapIterator_create(endpointDescription->properties); while (hashMapIterator_hasNext(iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); char *key = hashMapEntry_getKey(entry); char *value = hashMapEntry_getValue(entry); + properties_set(proxy_instance_ptr->properties, key, value); } + hashMapIterator_destroy(iter); } if (status == CELIX_SUCCESS) { http://git-wip-us.apache.org/repos/asf/celix/blob/cec955da/remote_services/topology_manager/private/src/activator.c ---------------------------------------------------------------------- diff --git a/remote_services/topology_manager/private/src/activator.c b/remote_services/topology_manager/private/src/activator.c index 5d7f8b0..b83c060 100644 --- a/remote_services/topology_manager/private/src/activator.c +++ b/remote_services/topology_manager/private/src/activator.c @@ -215,14 +215,14 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) celix_status_t status = CELIX_SUCCESS; struct activator *activator = userData; - if (serviceTracker_close(activator->endpointListenerTracker) == CELIX_SUCCESS) { - serviceTracker_destroy(activator->endpointListenerTracker); - } - if (serviceTracker_close(activator->remoteServiceAdminTracker) == CELIX_SUCCESS) { serviceTracker_destroy(activator->remoteServiceAdminTracker); } + if (serviceTracker_close(activator->endpointListenerTracker) == CELIX_SUCCESS) { + serviceTracker_destroy(activator->endpointListenerTracker); + } + bundleContext_removeServiceListener(context, activator->serviceListener); free(activator->serviceListener);