Repository: celix
Updated Branches:
  refs/heads/develop 83b124ffd -> dcd5bdafe


CELIX-438: Fixes an issue of double removings of components becuase the 
dm_deinit was triggered after the bundle_stop


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/dcd5bdaf
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/dcd5bdaf
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/dcd5bdaf

Branch: refs/heads/develop
Commit: dcd5bdafe8b69945734522707a01f125dc4f585b
Parents: 83b124f
Author: Pepijn Noltes <[email protected]>
Authored: Wed Dec 5 19:49:43 2018 +0100
Committer: Pepijn Noltes <[email protected]>
Committed: Wed Dec 5 19:49:43 2018 +0100

----------------------------------------------------------------------
 libs/dependency_manager/src/dm_activator.c      | 10 +++++-----
 libs/framework/src/dm_dependency_manager_impl.c | 17 ++++++++++++++---
 2 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/dcd5bdaf/libs/dependency_manager/src/dm_activator.c
----------------------------------------------------------------------
diff --git a/libs/dependency_manager/src/dm_activator.c 
b/libs/dependency_manager/src/dm_activator.c
index 8a99803..9a9da3f 100644
--- a/libs/dependency_manager/src/dm_activator.c
+++ b/libs/dependency_manager/src/dm_activator.c
@@ -31,11 +31,11 @@ celix_status_t bundleActivator_start(void *userData, 
celix_bundle_context_t *ctx
     return dm_init(userData, ctx, mng);
 }
 
-celix_status_t bundleActivator_stop(void * userData __attribute__((unused)), 
celix_bundle_context_t *ctx __attribute__((unused))) {
-    return CELIX_SUCCESS; //nothing to do (no dm_deinit)
-}
-
-celix_status_t bundleActivator_destroy(void * userData, celix_bundle_context_t 
*ctx __attribute__((unused))) {
+celix_status_t bundleActivator_stop(void * userData, celix_bundle_context_t 
*ctx) {
     dm_dependency_manager_t *mng = 
celix_bundleContext_getDependencyManager(ctx);
     return dm_destroy(userData, ctx, mng);
 }
+
+celix_status_t bundleActivator_destroy(void * userData  
__attribute__((unused)), celix_bundle_context_t *ctx __attribute__((unused))) {
+    return CELIX_SUCCESS; //nothing to do
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/dcd5bdaf/libs/framework/src/dm_dependency_manager_impl.c
----------------------------------------------------------------------
diff --git a/libs/framework/src/dm_dependency_manager_impl.c 
b/libs/framework/src/dm_dependency_manager_impl.c
index fec76d4..b306335 100644
--- a/libs/framework/src/dm_dependency_manager_impl.c
+++ b/libs/framework/src/dm_dependency_manager_impl.c
@@ -60,9 +60,20 @@ celix_status_t 
celix_dependencyManager_add(celix_dependency_manager_t *manager,
 celix_status_t celix_dependencyManager_remove(celix_dependency_manager_t 
*manager, celix_dm_component_t *component) {
        celix_status_t status;
 
-       celix_arrayList_remove(manager->components, component);
-       status = celix_private_dmComponent_stop(component);
-       component_destroy(component);
+       celix_array_list_entry_t entry;
+       memset(&entry, 0, sizeof(entry));
+       entry.voidPtrVal = component;
+       int index = celix_arrayList_indexOf(manager->components, entry);
+
+       if (index >= 0) {
+        celix_arrayList_removeAt(manager->components, index);
+        status = celix_private_dmComponent_stop(component);
+        component_destroy(component);
+       } else {
+           fprintf(stderr, "Cannot find component with pointer %p\n", 
component);
+           status = CELIX_BUNDLE_EXCEPTION;
+       }
+
 
        return status;
 }

Reply via email to