pnoltes commented on code in PR #734:
URL: https://github.com/apache/celix/pull/734#discussion_r1510900887


##########
libs/framework/src/bundle_context.c:
##########
@@ -839,7 +841,28 @@ static void 
celix_bundleContext_removeServiceTrackerTracker(void *data) {
     free(tracker);
 }
 
-static void celix_bundleContext_stopTrackerInternal(bundle_context_t *ctx, 
long trackerId, bool async, void *doneData, void (*doneCallback)(void* 
doneData)) {
+static void 
celix_bundleContext_waitForUnusedServiceTracker(celix_bundle_context_t* ctx,
+                                                            
celix_bundle_context_service_tracker_entry_t* trkEntry) {
+    // busy wait till the tracker is not used anymore
+    // note that the use count cannot be increased anymore, because the 
tracker is removed from the map
+    struct timespec start = celix_gettime(CLOCK_MONOTONIC);
+    int logCount = 0;
+    while (__atomic_load_n(&trkEntry->useCount, __ATOMIC_RELAXED) > 0) {

Review Comment:
   Thanks. I assumed ordering was not relevant, because a count increased only 
happened in the shared lock. 
   But indeed this check and thus the destroy of the tracking needs to be 
ordered after the use count decrease. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to