celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1658335 - in /celix/trunk/dependency_manager_2: private/include/ private/src/ public/include/
Date Mon, 09 Feb 2015 09:43:19 GMT
Author: abroekhuis
Date: Mon Feb  9 09:43:18 2015
New Revision: 1658335

URL: http://svn.apache.org/r1658335
Log:
Several small updates/code cleanup off the DM code.

Removed:
    celix/trunk/dependency_manager_2/private/include/dm_component_state_listener.h
Modified:
    celix/trunk/dependency_manager_2/private/src/dm_activator_base.c
    celix/trunk/dependency_manager_2/private/src/dm_component_impl.c
    celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c
    celix/trunk/dependency_manager_2/private/src/dm_service_dependency.c
    celix/trunk/dependency_manager_2/public/include/dm_component.h

Modified: celix/trunk/dependency_manager_2/private/src/dm_activator_base.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_activator_base.c?rev=1658335&r1=1658334&r2=1658335&view=diff
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_activator_base.c (original)
+++ celix/trunk/dependency_manager_2/private/src/dm_activator_base.c Mon Feb  9 09:43:18 2015
@@ -30,7 +30,7 @@ celix_status_t bundleActivator_create(bu
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
 
 	status = dependencyManager_create(dependency_activator->context, &dependency_activator->manager);
@@ -42,7 +42,7 @@ celix_status_t bundleActivator_start(voi
 	return status;
 }
 
-celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt __unused context)
{
 	celix_status_t status = CELIX_SUCCESS;
 	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
 
@@ -56,7 +56,7 @@ celix_status_t bundleActivator_stop(void
 	return status;
 }
 
-celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt __unused context)
{
 	celix_status_t status = CELIX_SUCCESS;
 	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
 

Modified: celix/trunk/dependency_manager_2/private/src/dm_component_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_component_impl.c?rev=1658335&r1=1658334&r2=1658335&view=diff
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_component_impl.c (original)
+++ celix/trunk/dependency_manager_2/private/src/dm_component_impl.c Mon Feb  9 09:43:18 2015
@@ -1,4 +1,4 @@
-/**
+#include <sys/cdefs.h>/**
  *Licensed to the Apache Software Foundation (ASF) under one
  *or more contributor license agreements.  See the NOTICE file
  *distributed with this work for additional information
@@ -39,7 +39,7 @@ struct dm_executor {
 
 struct dm_executor_task {
     dm_component_pt component;
-    void (*command)(void *command, void *data);
+    void (*command)(void *command_ptr, void *data);
     void *data;
 };
 
@@ -51,11 +51,11 @@ struct dm_handle_event_type {
 
 typedef struct dm_handle_event_type *dm_handle_event_type_pt;
 
-static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread);
+static celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t  __unused currentThread);
 static celix_status_t executor_execute(dm_executor_pt executor);
 static celix_status_t executor_executeTask(dm_executor_pt executor, dm_component_pt component,
void (*command), void *data);
 static celix_status_t executor_schedule(dm_executor_pt executor, dm_component_pt component,
void (*command), void *data);
-static celix_status_t executor_create(dm_component_pt component, dm_executor_pt *executor);
+static celix_status_t executor_create(dm_component_pt  __unused component, dm_executor_pt
*executor);
 static celix_status_t executor_destroy(dm_executor_pt *executor);
 
 static celix_status_t component_destroyComponent(dm_component_pt component);
@@ -72,11 +72,11 @@ static celix_status_t component_allRequi
 static celix_status_t component_performTransition(dm_component_pt component, dm_component_state_pt
oldState, dm_component_state_pt newState, bool *transition);
 static celix_status_t component_calculateNewState(dm_component_pt component, dm_component_state_pt
currentState, dm_component_state_pt *newState);
 static celix_status_t component_handleChange(dm_component_pt component);
-static celix_status_t component_startDependencies(dm_component_pt component, array_list_pt
dependencies);
+static celix_status_t component_startDependencies(dm_component_pt  __unused component, array_list_pt
dependencies);
 
 static celix_status_t component_addTask(dm_component_pt component, array_list_pt dependencies);
-static celix_status_t component_startTask(dm_component_pt component, void* data);
-static celix_status_t component_stopTask(dm_component_pt component, void* data);
+static celix_status_t component_startTask(dm_component_pt component, void __unused * data);
+static celix_status_t component_stopTask(dm_component_pt component, void __unused * data);
 static celix_status_t component_removeTask(dm_component_pt component, dm_service_dependency_pt
dependency);
 static celix_status_t component_handleEventTask(dm_component_pt component, dm_handle_event_type_pt
data);
 
@@ -173,7 +173,7 @@ celix_status_t component_addTask(dm_comp
 
     array_list_pt bounds = NULL;
     arrayList_create(&bounds);
-    for (int i = 0; i < arrayList_size(dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
 
         pthread_mutex_lock(&component->mutex);
@@ -185,7 +185,7 @@ celix_status_t component_addTask(dm_comp
         pthread_mutex_unlock(&component->mutex);
 
         serviceDependency_setComponent(dependency, component);
-        if (!(component->state == DM_CMP_STATE_INACTIVE)) {
+        if (component->state != DM_CMP_STATE_INACTIVE) {
             serviceDependency_setInstanceBound(dependency, true);
             arrayList_add(bounds, dependency);
         }
@@ -215,13 +215,13 @@ celix_status_t component_removeTask(dm_c
     arrayList_removeElement(component->dependencies, dependency);
     pthread_mutex_unlock(&component->mutex);
 
-    if (!(component->state == DM_CMP_STATE_INACTIVE)) {
+    if (component->state != DM_CMP_STATE_INACTIVE) {
         serviceDependency_stop(dependency);
     }
 
     pthread_mutex_lock(&component->mutex);
     array_list_pt events = hashMap_remove(component->dependencyEvents, dependency);
-    for (int i = arrayList_size(events); i > 0; i--) {
+    for (unsigned int i = arrayList_size(events); i > 0; i--) {
     	dm_event_pt event = arrayList_remove(events, i - 1);
     	event_destroy(&event);
     }
@@ -243,7 +243,7 @@ celix_status_t component_start(dm_compon
     return status;
 }
 
-celix_status_t component_startTask(dm_component_pt component, void* data) {
+celix_status_t component_startTask(dm_component_pt component, void __unused *data) {
     celix_status_t status = CELIX_SUCCESS;
 
     component->isStarted = true;
@@ -262,7 +262,7 @@ celix_status_t component_stop(dm_compone
     return status;
 }
 
-celix_status_t component_stopTask(dm_component_pt component, void* data) {
+celix_status_t component_stopTask(dm_component_pt component, void __unused *data) {
     celix_status_t status = CELIX_SUCCESS;
 
     component->isStarted = false;
@@ -379,29 +379,33 @@ celix_status_t component_handleChanged(d
     pthread_mutex_lock(&component->mutex);
     array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
     int index = arrayList_indexOf(events, event);
-    dm_event_pt old = arrayList_remove(events, index);
-    arrayList_add(events, event);
-    pthread_mutex_unlock(&component->mutex);
+    if (index < 0) {
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        arrayList_add(events, event);
+        pthread_mutex_unlock(&component->mutex);
 
-    switch (component->state) {
-        case DM_CMP_STATE_TRACKING_OPTIONAL:
-            serviceDependency_invokeChange(dependency, event);
-            // updateInstance
-            break;
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-            bool instanceBound = false;
-            serviceDependency_isInstanceBound(dependency, &instanceBound);
-            if (!instanceBound) {
+        switch (component->state) {
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
                 serviceDependency_invokeChange(dependency, event);
                 // updateInstance
+                break;
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    serviceDependency_invokeChange(dependency, event);
+                    // updateInstance
+                }
+                break;
             }
-            break;
+            default:
+                break;
         }
-        default:
-            break;
-    }
 
-    event_destroy(&old);
+        event_destroy(&old);
+    }
 
     return status;
 }
@@ -421,34 +425,38 @@ celix_status_t component_handleRemoved(d
 
     pthread_mutex_lock(&component->mutex);
     int index = arrayList_indexOf(events, event);
-	dm_event_pt old = arrayList_remove(events, index);
-	pthread_mutex_unlock(&component->mutex);
+    if (index < 0) {
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        pthread_mutex_unlock(&component->mutex);
 
-    switch (component->state) {
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
-            bool instanceBound = false;
-            serviceDependency_isInstanceBound(dependency, &instanceBound);
-            if (!instanceBound) {
-                bool required = false;
-                serviceDependency_isRequired(dependency, &required);
-                if (required) {
-                    serviceDependency_invokeRemove(dependency, event);
+        switch (component->state) {
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    bool required = false;
+                    serviceDependency_isRequired(dependency, &required);
+                    if (required) {
+                        serviceDependency_invokeRemove(dependency, event);
+                    }
+                    // updateInstance
                 }
-                // updateInstance
+                break;
             }
-            break;
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
+                serviceDependency_invokeRemove(dependency, event);
+                // updateInstance
+                break;
+            default:
+                break;
         }
-        case DM_CMP_STATE_TRACKING_OPTIONAL:
-            serviceDependency_invokeRemove(dependency, event);
-            // updateInstance
-            break;
-        default:
-            break;
-    }
 
-    event_destroy(&event);
-    if (old) {
-    	event_destroy(&old);
+        event_destroy(&event);
+        if (old) {
+            event_destroy(&old);
+        }
     }
 
     return status;
@@ -460,64 +468,67 @@ celix_status_t component_handleSwapped(d
     pthread_mutex_lock(&component->mutex);
     array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
     int index = arrayList_indexOf(events, event);
-	dm_event_pt old = arrayList_remove(events, index);
-    arrayList_add(events, newEvent);
-    pthread_mutex_unlock(&component->mutex);
+    if (index < 0) {
+        status = CELIX_BUNDLE_EXCEPTION;
+    } else {
+        dm_event_pt old = arrayList_remove(events, (unsigned int) index);
+        arrayList_add(events, newEvent);
+        pthread_mutex_unlock(&component->mutex);
 
-    switch (component->state) {
-        case DM_CMP_STATE_WAITING_FOR_REQUIRED:
-            break;
-        case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED:
-        {
-            bool instanceBound = false;
-            serviceDependency_isInstanceBound(dependency, &instanceBound);
-            if (!instanceBound) {
-                bool required = false;
-                serviceDependency_isRequired(dependency, &required);
-                if (required) {
-                    serviceDependency_invokeSwap(dependency, event, newEvent);
+        switch (component->state) {
+            case DM_CMP_STATE_WAITING_FOR_REQUIRED:
+                break;
+            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED: {
+                bool instanceBound = false;
+                serviceDependency_isInstanceBound(dependency, &instanceBound);
+                if (!instanceBound) {
+                    bool required = false;
+                    serviceDependency_isRequired(dependency, &required);
+                    if (required) {
+                        serviceDependency_invokeSwap(dependency, event, newEvent);
+                    }
                 }
+                break;
             }
-            break;
+            case DM_CMP_STATE_TRACKING_OPTIONAL:
+                serviceDependency_invokeSwap(dependency, event, newEvent);
+                break;
+            default:
+                break;
         }
-        case DM_CMP_STATE_TRACKING_OPTIONAL:
-            serviceDependency_invokeSwap(dependency, event, newEvent);
-            break;
-        default:
-            break;
-    }
 
-    event_destroy(&event);
-	if (old) {
-		event_destroy(&old);
-	}
+        event_destroy(&event);
+        if (old) {
+            event_destroy(&old);
+        }
+    }
 
     return status;
 }
 
-celix_status_t component_startDependencies(dm_component_pt component, array_list_pt dependencies)
{
+celix_status_t component_startDependencies(dm_component_pt __unused component, array_list_pt
dependencies) {
     celix_status_t status = CELIX_SUCCESS;
-    array_list_pt requiredDeps = NULL;
-    arrayList_create(&requiredDeps);
+    array_list_pt required_dependencies = NULL;
+    arrayList_create(&required_dependencies);
 
-    for (int i = 0; i < arrayList_size(dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(dependencies, i);
         bool required = false;
         serviceDependency_isRequired(dependency, &required);
         if (required) {
-            arrayList_add(requiredDeps, dependency);
+            arrayList_add(required_dependencies, dependency);
             continue;
         }
 
         serviceDependency_start(dependency);
     }
 
-    for (int i = 0; i < arrayList_size(requiredDeps); i++) {
-        dm_service_dependency_pt dependency = arrayList_get(requiredDeps, i);
+    for (unsigned int i = 0; i < arrayList_size(required_dependencies); i++) {
+        dm_service_dependency_pt dependency = arrayList_get(required_dependencies, i);
         serviceDependency_start(dependency);
     }
 
-    arrayList_destroy(requiredDeps);
+    arrayList_destroy(required_dependencies);
 
     return status;
 }
@@ -526,7 +537,7 @@ celix_status_t component_stopDependencie
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
         pthread_mutex_unlock(&component->mutex);
         serviceDependency_stop(dependency);
@@ -678,11 +689,11 @@ celix_status_t component_performTransiti
         component_invokeRemoveRequiredDependencies(component);
 //            #TODO Add listener support
 //        notifyListeners(newState);
-        bool needInstance = false;
+//        bool needInstance = false;
 //        component_someDependenciesNeedInstance(component, &needInstance);
-        if (!needInstance) {
+//        if (!needInstance) {
             component_destroyComponent(component);
-        }
+//        }
         *transition = true;
         return status;
     }
@@ -705,7 +716,7 @@ celix_status_t component_allRequiredAvai
 
     pthread_mutex_lock(&component->mutex);
     *available = true;
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
         bool required = false;
         bool instanceBound = false;
@@ -732,7 +743,7 @@ celix_status_t component_allInstanceBoun
 
     pthread_mutex_lock(&component->mutex);
     *available = true;
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
         bool required = false;
         bool instanceBound = false;
@@ -758,7 +769,7 @@ celix_status_t component_invokeAddRequir
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool required = false;
@@ -770,8 +781,8 @@ celix_status_t component_invokeAddRequir
         if (required && !instanceBound) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeAdd(dependency, event);
 				}
             }
@@ -786,7 +797,7 @@ celix_status_t component_invokeAddRequir
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool required = false;
@@ -798,8 +809,8 @@ celix_status_t component_invokeAddRequir
         if (instanceBound && required) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeAdd(dependency, event);
 				}
             }
@@ -814,7 +825,7 @@ celix_status_t component_invokeAddOption
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool required = false;
@@ -824,8 +835,8 @@ celix_status_t component_invokeAddOption
         if (!required) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeAdd(dependency, event);
 				}
             }
@@ -840,7 +851,7 @@ celix_status_t component_invokeRemoveOpt
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool required = false;
@@ -850,8 +861,8 @@ celix_status_t component_invokeRemoveOpt
         if (!required) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeRemove(dependency, event);
 				}
             }
@@ -866,7 +877,7 @@ celix_status_t component_invokeRemoveIns
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool instanceBound = false;
@@ -876,8 +887,8 @@ celix_status_t component_invokeRemoveIns
         if (instanceBound) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeRemove(dependency, event);
 				}
             }
@@ -892,7 +903,7 @@ celix_status_t component_invokeRemoveReq
     celix_status_t status = CELIX_SUCCESS;
 
     pthread_mutex_lock(&component->mutex);
-    for (int i = 0; i < arrayList_size(component->dependencies); i++) {
+    for (unsigned int i = 0; i < arrayList_size(component->dependencies); i++) {
         dm_service_dependency_pt dependency = arrayList_get(component->dependencies, i);
 
         bool required = false;
@@ -904,8 +915,8 @@ celix_status_t component_invokeRemoveReq
         if (!instanceBound && required) {
             array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
             if (events) {
-				for (int i = 0; i < arrayList_size(events); i++) {
-					dm_event_pt event = arrayList_get(events, i);
+				for (unsigned int j = 0; j < arrayList_size(events); j++) {
+					dm_event_pt event = arrayList_get(events, j);
 					serviceDependency_invokeRemove(dependency, event);
 				}
             }
@@ -981,7 +992,7 @@ celix_status_t component_getBundleContex
 }
 
 
-celix_status_t executor_create(dm_component_pt component, dm_executor_pt *executor) {
+celix_status_t executor_create(dm_component_pt __unused component, dm_executor_pt *executor)
{
     celix_status_t status = CELIX_SUCCESS;
 
     *executor = malloc(sizeof(**executor));
@@ -1072,7 +1083,7 @@ celix_status_t executor_execute(dm_execu
     return status;
 }
 
-celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t currentThread) {
+celix_status_t executor_runTasks(dm_executor_pt executor, pthread_t __unused currentThread)
{
     celix_status_t status = CELIX_SUCCESS;
 //    bool execute = false;
 

Modified: celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c?rev=1658335&r1=1658334&r2=1658335&view=diff
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c (original)
+++ celix/trunk/dependency_manager_2/private/src/dm_dependency_manager_impl.c Mon Feb  9 09:43:18
2015
@@ -2,10 +2,7 @@
 #include <stdlib.h>
 
 #include "bundle_context.h"
-#include "celix_errno.h"
-#include "array_list.h"
 #include "dm_component_impl.h"
-#include "dm_dependency_manager.h"
 
 struct dm_dependency_manager {
 	array_list_pt components;
@@ -13,7 +10,7 @@ struct dm_dependency_manager {
 	pthread_mutex_t mutex;
 };
 
-celix_status_t dependencyManager_create(bundle_context_pt context, dm_dependency_manager_pt
*manager) {
+celix_status_t dependencyManager_create(bundle_context_pt __unused context, dm_dependency_manager_pt
*manager) {
 	celix_status_t status = CELIX_ENOMEM;
 
 	(*manager) = calloc(1, sizeof(**manager));
@@ -40,7 +37,7 @@ celix_status_t dependencyManager_destroy
 }
 
 celix_status_t dependencyManager_add(dm_dependency_manager_pt manager, dm_component_pt component)
{
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 
 	arrayList_add(manager->components, component);
 	status = component_start(component);
@@ -49,7 +46,7 @@ celix_status_t dependencyManager_add(dm_
 }
 
 celix_status_t dependencyManager_remove(dm_dependency_manager_pt manager, dm_component_pt
component) {
-	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status;
 
 	arrayList_removeElement(manager->components, component);
 	status = component_stop(component);

Modified: celix/trunk/dependency_manager_2/private/src/dm_service_dependency.c
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/private/src/dm_service_dependency.c?rev=1658335&r1=1658334&r2=1658335&view=diff
==============================================================================
--- celix/trunk/dependency_manager_2/private/src/dm_service_dependency.c (original)
+++ celix/trunk/dependency_manager_2/private/src/dm_service_dependency.c Mon Feb  9 09:43:18
2015
@@ -31,7 +31,6 @@
 
 #include "dm_service_dependency_impl.h"
 #include "dm_component_impl.h"
-#include "dm_event.h"
 
 static celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference,
void *service);
 static celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt
reference, void *service);
@@ -116,10 +115,10 @@ celix_status_t serviceDependency_setServ
 			if (serviceName == NULL) {
 				dependency->tracked_filter = strdup(filter);
 			} else {
-				int len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + strlen(filter) +
7;
-				char nfilter[len];
-				snprintf(nfilter, len, "(&(%s=%s)%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName, filter);
-				dependency->tracked_filter = strdup(nfilter);
+				size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + strlen(filter)
+ 7;
+				char new_filter[len];
+				snprintf(new_filter, len, "(&(%s=%s)%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName,
filter);
+				dependency->tracked_filter = strdup(new_filter);
 			}
 		} else {
 			dependency->tracked_filter_unmodified = NULL;
@@ -177,7 +176,7 @@ celix_status_t serviceDependency_setComp
 
 celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
 	celix_status_t status = CELIX_SUCCESS;
-	bundle_context_pt context;
+	bundle_context_pt context = NULL;
 
 	if (!dependency || !dependency->component || (!dependency->tracked_service_name &&
!dependency->tracked_filter)) {
 		status = CELIX_ILLEGAL_ARGUMENT;
@@ -217,6 +216,7 @@ celix_status_t serviceDependency_start(d
 
 celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
 	celix_status_t status = CELIX_SUCCESS;
+    celix_status_t tmp_status;
 
 	if (!dependency) {
 		status = CELIX_ILLEGAL_ARGUMENT;
@@ -224,8 +224,14 @@ celix_status_t serviceDependency_stop(dm
 
 	if (status == CELIX_SUCCESS) {
 		if (dependency->tracker) {
-			status = serviceTracker_close(dependency->tracker);
-			status = serviceTracker_destroy(dependency->tracker);
+            tmp_status = serviceTracker_close(dependency->tracker);
+            if (tmp_status != CELIX_SUCCESS) {
+                status = tmp_status;
+            }
+			tmp_status = serviceTracker_destroy(dependency->tracker);
+            if (tmp_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+                status = tmp_status;
+            }
 		}
 	}
 

Modified: celix/trunk/dependency_manager_2/public/include/dm_component.h
URL: http://svn.apache.org/viewvc/celix/trunk/dependency_manager_2/public/include/dm_component.h?rev=1658335&r1=1658334&r2=1658335&view=diff
==============================================================================
--- celix/trunk/dependency_manager_2/public/include/dm_component.h (original)
+++ celix/trunk/dependency_manager_2/public/include/dm_component.h Mon Feb  9 09:43:18 2015
@@ -43,6 +43,7 @@ typedef celix_status_t (*destroy_fpt)(vo
 celix_status_t component_create(bundle_context_pt context, dm_dependency_manager_pt manager,
dm_component_pt *component);
 celix_status_t component_destroy(dm_component_pt *component);
 
+celix_status_t component_setInterface(dm_component_pt component, char *serviceName, properties_pt
properties);
 celix_status_t component_setImplementation(dm_component_pt component, void *implementation);
 
 celix_status_t component_addServiceDependency(dm_component_pt component, ...);



Mime
View raw message