celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [celix] pnoltes commented on a change in pull request #317: prevents unneeded suspend triggers in the dm component
Date Mon, 15 Feb 2021 10:59:11 GMT

pnoltes commented on a change in pull request #317:
URL: https://github.com/apache/celix/pull/317#discussion_r576108265



##########
File path: libs/framework/src/service_tracker.c
##########
@@ -163,26 +163,56 @@ celix_status_t serviceTracker_destroy(service_tracker_pt tracker) {
 
 celix_status_t serviceTracker_open(service_tracker_pt tracker) {
     celixThreadMutex_lock(&tracker->mutex);
-    bool alreadyOpen = tracker->open;
-    tracker->open = true;
+    bool addListener = false;
+    switch (tracker->state) {
+        case CELIX_SERVICE_TRACKER_CLOSED:
+            tracker->state = CELIX_SERVICE_TRACKER_OPENING;
+            addListener = true;
+            break;
+        case CELIX_SERVICE_TRACKER_CLOSING:
+            celix_bundleContext_log(tracker->context, CELIX_LOG_LEVEL_WARNING, "Cannot
open closing tracker");
+            break;
+        default:
+            //nop
+            break;
+    }
     celixThreadMutex_unlock(&tracker->mutex);
 
-    if (!alreadyOpen) {
+    if (!addListener) {

Review comment:
       this was a bug. In combination with the wrong init of the initial state, this did not
trigger test failures.
   Updated this. 




----------------------------------------------------------------
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.

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



Mime
View raw message