Repository: celix Updated Branches: refs/heads/develop 18a5bf743 -> e5acd9069
CELIX-308: Apply dm_leak path Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/f1759bde Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/f1759bde Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/f1759bde Branch: refs/heads/develop Commit: f1759bde6805b66473b2bd7553b0004e6657dfbe Parents: 18a5bf7 Author: Pepijn Noltes <pepijnnol...@gmail.com> Authored: Fri Nov 27 15:58:07 2015 +0100 Committer: Pepijn Noltes <pepijnnol...@gmail.com> Committed: Fri Nov 27 15:58:07 2015 +0100 ---------------------------------------------------------------------- .../private/src/dm_component_impl.c | 26 ++++++++++---- .../private/src/dm_dependency_manager_impl.c | 38 +++++++++----------- .../private/src/dm_shell_list_command.c | 8 +++++ .../phase3/private/src/phase3_activator.c | 3 -- .../dm_example/phase3/private/src/phase3_cmp.c | 2 ++ shell/private/src/help_command.c | 1 + 6 files changed, 48 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/dependency_manager/private/src/dm_component_impl.c ---------------------------------------------------------------------- diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c index f368e7d..969c592 100644 --- a/dependency_manager/private/src/dm_component_impl.c +++ b/dependency_manager/private/src/dm_component_impl.c @@ -171,18 +171,30 @@ void component_destroy(dm_component_pt component) { for (i = 0; i < arrayList_size(component->dm_interfaces); i++) { dm_interface_t *interface = arrayList_get(component->dm_interfaces, i); + if(interface->properties!=NULL){ + properties_destroy(interface->properties); + } free (interface->serviceName); free (interface); } arrayList_destroy(component->dm_interfaces); - // #TODO destroy dependencies - executor_destroy(component->executor); - //TODO free events + + hash_map_iterator_pt iter = hashMapIterator_create(component->dependencyEvents); + while(hashMapIterator_hasNext(iter)){ + hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); + dm_service_dependency_pt sdep = (dm_service_dependency_pt)hashMapEntry_getKey(entry); + array_list_pt eventList = (array_list_pt)hashMapEntry_getValue(entry); + serviceDependency_destroy(&sdep); + arrayList_destroy(eventList); + } + hashMapIterator_destroy(iter); + hashMap_destroy(component->dependencyEvents, false, false); - pthread_mutex_destroy(&component->mutex); + arrayList_destroy(component->dependencies); + pthread_mutex_destroy(&component->mutex); free(component); } @@ -260,6 +272,8 @@ celix_status_t component_removeTask(dm_component_pt component, dm_service_depend array_list_pt events = hashMap_remove(component->dependencyEvents, dependency); pthread_mutex_unlock(&component->mutex); + serviceDependency_destroy(&dependency); + while (!arrayList_isEmpty(events)) { dm_event_pt event = arrayList_remove(events, 0); event_destroy(&event); @@ -762,18 +776,18 @@ celix_status_t component_performTransition(dm_component_pt component, dm_compone } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_TRACKING_OPTIONAL) { component_invokeAddRequiredInstanceBoundDependencies(component); component_invokeAutoConfigInstanceBoundDependencies(component); + component_invokeAddOptionalDependencies(component); if (component->callbackStart) { status = component->callbackStart(component->implementation); } - component_invokeAddOptionalDependencies(component); component_registerServices(component); *transition = true; } else if (oldState == DM_CMP_STATE_TRACKING_OPTIONAL && newState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED) { component_unregisterServices(component); - component_invokeRemoveOptionalDependencies(component); if (component->callbackStop) { status = component->callbackStop(component->implementation); } + component_invokeRemoveOptionalDependencies(component); component_invokeRemoveInstanceBoundDependencies(component); *transition = true; } else if (oldState == DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == DM_CMP_STATE_WAITING_FOR_REQUIRED) { http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/dependency_manager/private/src/dm_dependency_manager_impl.c ---------------------------------------------------------------------- diff --git a/dependency_manager/private/src/dm_dependency_manager_impl.c b/dependency_manager/private/src/dm_dependency_manager_impl.c index 7ee9287..511ef1e 100644 --- a/dependency_manager/private/src/dm_dependency_manager_impl.c +++ b/dependency_manager/private/src/dm_dependency_manager_impl.c @@ -52,9 +52,7 @@ celix_status_t dependencyManager_create(bundle_context_pt context __attribute__( void dependencyManager_destroy(dm_dependency_manager_pt manager) { if (manager != NULL) { - //TODO destroy components arrayList_destroy(manager->components); - free(manager); } } @@ -71,15 +69,19 @@ celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_compon celix_status_t depedencyManager_removeAllComponents(dm_dependency_manager_pt manager) { celix_status_t status; + unsigned int i=0; + unsigned int size = arrayList_size(manager->components); + + for(;i<size;i++){ + dm_component_pt cmp = arrayList_get(manager->components, i); + printf("Stopping comp %s\n", component_getName(cmp)); + status += component_stop(cmp); + } + while (!arrayList_isEmpty(manager->components)) { dm_component_pt cmp = arrayList_remove(manager->components, 0); printf("Removing comp %s\n", component_getName(cmp)); - status = component_stop(cmp); - //TODO component_destroy(&cmp); - - if (status != CELIX_SUCCESS) { - break; - } + component_destroy(cmp); } return status; @@ -117,20 +119,14 @@ celix_status_t dependencyManager_getInfo(dm_dependency_manager_pt manager, dm_de } void dependencyManager_destroyInfo(dm_dependency_manager_pt manager, dm_dependency_manager_info_pt info) { - return; - /* - * TODO - - int i; - int size; - if (info != NULL) { - size = arrayList_size(info->components); - for (i = 0; i < size; i += 1) { - dm_component_info_pt cmpInfo = arrayList_get(info->components, i); - component_destroyComponentInfo(cmpInfo); + + unsigned int i = 0; + for(;i<arrayList_size(info->components);i++){ + dm_component_info_pt cmpinfo = (dm_component_info_pt)arrayList_get(info->components,0); + component_destroyComponentInfo(cmpinfo); } arrayList_destroy(info->components); - } + free(info); - */ + } http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/dependency_manager/private/src/dm_shell_list_command.c ---------------------------------------------------------------------- diff --git a/dependency_manager/private/src/dm_shell_list_command.c b/dependency_manager/private/src/dm_shell_list_command.c index fd7c5d9..4862d42 100644 --- a/dependency_manager/private/src/dm_shell_list_command.c +++ b/dependency_manager/private/src/dm_shell_list_command.c @@ -102,7 +102,15 @@ void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FI } fprintf(out, "\n"); + } + infoServ->destroyInfo(infoServ->handle, info); + + bundleContext_ungetService(context,servRef,NULL); + } + + if(servRefs!=NULL){ + arrayList_destroy(servRefs); } } http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/examples/dm_example/phase3/private/src/phase3_activator.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/private/src/phase3_activator.c b/examples/dm_example/phase3/private/src/phase3_activator.c index d79b785..74f6bb2 100644 --- a/examples/dm_example/phase3/private/src/phase3_activator.c +++ b/examples/dm_example/phase3/private/src/phase3_activator.c @@ -50,9 +50,6 @@ celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency act->phase3Cmp = phase3_create(); if (act->phase3Cmp != NULL) { - properties_pt props = properties_create(); - properties_set(props, "id", "phase3"); - dm_component_pt cmp; component_create(context, "PHASE3_PROCESSING_COMPONENT", &cmp); component_setImplementation(cmp, act->phase3Cmp); http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/examples/dm_example/phase3/private/src/phase3_cmp.c ---------------------------------------------------------------------- diff --git a/examples/dm_example/phase3/private/src/phase3_cmp.c b/examples/dm_example/phase3/private/src/phase3_cmp.c index 6f5b99b..f8ca948 100644 --- a/examples/dm_example/phase3/private/src/phase3_cmp.c +++ b/examples/dm_example/phase3/private/src/phase3_cmp.c @@ -82,6 +82,8 @@ int phase3_deinit(phase3_cmp_t *cmp) { void phase3_destroy(phase3_cmp_t *cmp) { celixThreadMutex_lock(&cmp->mutex); + arrayList_destroy(cmp->phase2Services); + celixThreadMutex_unlock(&cmp->mutex); celixThreadMutex_destroy(&cmp->mutex); free(cmp); printf("destroy phase3\n"); http://git-wip-us.apache.org/repos/asf/celix/blob/f1759bde/shell/private/src/help_command.c ---------------------------------------------------------------------- diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c index b8408ad..48615ae 100644 --- a/shell/private/src/help_command.c +++ b/shell/private/src/help_command.c @@ -72,6 +72,7 @@ celix_status_t helpCommand_execute(void *_ptr, char *line_str, FILE *out_ptr, FI fprintf(out_ptr, "%s\n", name); } fprintf(out_ptr, "\nUse 'help <command-name>' for more information.\n"); + arrayList_destroy(commands); } else { celix_status_t sub_status_desc; celix_status_t sub_status_usage;