PengZheng commented on code in PR #476:
URL: https://github.com/apache/celix/pull/476#discussion_r1114372525


##########
libs/framework/src/framework_bundle_lifecycle_handler.c:
##########
@@ -83,31 +90,32 @@ void 
celix_framework_cleanupBundleLifecycleHandlers(celix_framework_t* fw, bool
     celixThreadMutex_unlock(&fw->bundleLifecycleHandling.mutex);
 }
 
-static void 
celix_framework_createAndStartBundleLifecycleHandler(celix_framework_t* fw, 
celix_framework_bundle_entry_t* bndEntry, enum celix_bundle_lifecycle_command 
bndCommand) {
+static void 
celix_framework_createAndStartBundleLifecycleHandler(celix_framework_t* fw, 
celix_framework_bundle_entry_t* bndEntry, enum celix_bundle_lifecycle_command 
bndCommand, const char* updatedBundleUrl) {
     celix_framework_bundleEntry_increaseUseCount(bndEntry);
     celixThreadMutex_lock(&fw->bundleLifecycleHandling.mutex);
     celix_framework_bundle_lifecycle_handler_t* handler = calloc(1, 
sizeof(*handler));
     handler->command = bndCommand;
     handler->framework = fw;
     handler->bndEntry = bndEntry;
     handler->bndId = bndEntry->bndId;
+    handler->updatedBundleUrl = celix_utils_strdup(updatedBundleUrl);
     celix_arrayList_add(fw->bundleLifecycleHandling.bundleLifecycleHandlers, 
handler);
 
     fw_log(fw->logger, CELIX_LOG_LEVEL_TRACE, "Creating thread for %s bundle 
%li",
            celix_bundleLifecycleCommand_getDesc(handler->command) , 
handler->bndId);
-    celixThread_create(&handler->thread, NULL, 
celix_framework_stopStartBundleThread, handler);
+    celixThread_create(&handler->thread, NULL, 
celix_framework_BundleLifecycleHandlingThread, handler);

Review Comment:
   ~~Pthread is joinable by default. Without a `pthread_join`, resource leak 
happens. 
   See `man 7 pthread_detach` for remedies.~~
   
   ~~We need to check every `celixThread_create` to make sure either 
`pthread_join` or `pthread_detach`~~
   
   I am happy to know I was wrong: 
`celix_framework_cleanupBundleLifecycleHandlers` calls `celixThread_join` on 
these handlers. However, a problem remains:
   
   Note that `celix_framework_cleanupBundleLifecycleHandlers` is only called by 
`framework_shutdown`. What if I keep start/stop bundles so that resource 
consumption keeps growing?



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