You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by bp...@apache.org on 2015/10/07 12:50:07 UTC
celix git commit: CELIX-190: fixed some remote services
leaks/race-conditions
Repository: celix
Updated Branches:
refs/heads/develop 397510293 -> cec955da8
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/develop
Commit: cec955da8b17d6c0f9ae9353223e34dda7fa50fe
Parents: 3975102
Author: Bjoern Petri <bp...@apache.org>
Authored: Wed Oct 7 12:49:34 2015 +0200
Committer: Bjoern Petri <bp...@apache.org>
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);