celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [10/50] celix git commit: CELIX-344: Fix wrong assumption that a service references always is tracked when untracking int the service tracker.
Date Mon, 11 Apr 2016 12:00:19 GMT
CELIX-344: Fix wrong assumption that a service references always is tracked when untracking
int the service tracker.


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

Branch: refs/heads/master
Commit: c4a34a9802f7a9a75fd4e819915fd6de189f92a0
Parents: 37010fb
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Thu Feb 4 15:55:38 2016 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Thu Feb 4 15:55:38 2016 +0100

----------------------------------------------------------------------
 framework/private/src/service_tracker.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/c4a34a98/framework/private/src/service_tracker.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_tracker.c b/framework/private/src/service_tracker.c
index 1d4e4aa..42ac254 100644
--- a/framework/private/src/service_tracker.c
+++ b/framework/private/src/service_tracker.c
@@ -382,6 +382,7 @@ static celix_status_t serviceTracker_untrack(service_tracker_pt tracker,
service
     celix_status_t status = CELIX_SUCCESS;
     tracked_pt tracked = NULL;
     unsigned int i;
+    bool found = false;
 
     celixThreadRwlock_writeLock(&tracker->lock);
     for (i = 0; i < arrayList_size(tracker->trackedServices); i++) {
@@ -389,13 +390,14 @@ static celix_status_t serviceTracker_untrack(service_tracker_pt tracker,
service
         tracked = (tracked_pt) arrayList_get(tracker->trackedServices, i);
         serviceReference_equals(reference, tracked->reference, &equals);
         if (equals) {
+            found = true;
             arrayList_remove(tracker->trackedServices, i);
             break;
         }
     }
     celixThreadRwlock_unlock(&tracker->lock);
 
-    if (tracked != NULL) {
+    if (found && tracked != NULL) {
         serviceTracker_invokeRemovingService(tracker, tracked->reference, tracked->service);
         free(tracked);
         bundleContext_ungetServiceReference(tracker->context, reference);


Mime
View raw message